edits for BPY_extern.h functions, no functional changes
- remove unused code. - BPY_run_python_script() split in 2, BPY_filepath_exec, BPY_text_exec - renamed funcs.
This commit is contained in:
@@ -2033,7 +2033,7 @@ static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targ
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Now, run the actual 'constraint' function, which should only access the matrices */
|
/* Now, run the actual 'constraint' function, which should only access the matrices */
|
||||||
BPY_pyconstraint_eval(data, cob, targets);
|
BPY_pyconstraint_exec(data, cob, targets);
|
||||||
#endif /* WITH_PYTHON */
|
#endif /* WITH_PYTHON */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -427,8 +427,8 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res
|
|||||||
memset(result, 0, sizeof(bContextDataResult));
|
memset(result, 0, sizeof(bContextDataResult));
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
if(CTX_py_dict_get(C)) {
|
if(CTX_py_dict_get(C)) {
|
||||||
return BPY_context_get(C, member, result);
|
return BPY_context_member_get(C, member, result);
|
||||||
// if (BPY_context_get(C, member, result))
|
// if (BPY_context_member_get(C, member, result))
|
||||||
// return 1;
|
// return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -492,12 +492,7 @@ int BKE_read_exotic(Scene *scene, const char *name)
|
|||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
// TODO: this should not be in the kernel...
|
// TODO: this should not be in the kernel...
|
||||||
else { // unknown format, call Python importloader
|
else { // unknown format, call Python importloader
|
||||||
if (BPY_call_importloader(name)) {
|
/* pass */
|
||||||
retval = 1;
|
|
||||||
} else {
|
|
||||||
//XXX error("Unknown file type or error, check console");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* WITH_PYTHON */
|
#endif /* WITH_PYTHON */
|
||||||
//XXX waitcursor(0);
|
//XXX waitcursor(0);
|
||||||
|
@@ -1514,7 +1514,7 @@ static float evaluate_driver (ChannelDriver *driver, float UNUSED(evaltime))
|
|||||||
/* this evaluates the expression using Python,and returns its result:
|
/* this evaluates the expression using Python,and returns its result:
|
||||||
* - on errors it reports, then returns 0.0f
|
* - on errors it reports, then returns 0.0f
|
||||||
*/
|
*/
|
||||||
driver->curval= BPY_eval_driver(driver);
|
driver->curval= BPY_driver_exec(driver);
|
||||||
}
|
}
|
||||||
#endif /* WITH_PYTHON*/
|
#endif /* WITH_PYTHON*/
|
||||||
}
|
}
|
||||||
|
@@ -168,7 +168,7 @@ void free_text(Text *text)
|
|||||||
if(text->name) MEM_freeN(text->name);
|
if(text->name) MEM_freeN(text->name);
|
||||||
MEM_freeN(text->undo_buf);
|
MEM_freeN(text->undo_buf);
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
if (text->compiled) BPY_free_compiled_text(text);
|
if (text->compiled) BPY_text_free_code(text);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -684,7 +684,7 @@ static void txt_make_dirty (Text *text)
|
|||||||
{
|
{
|
||||||
text->flags |= TXT_ISDIRTY;
|
text->flags |= TXT_ISDIRTY;
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
if (text->compiled) BPY_free_compiled_text(text);
|
if (text->compiled) BPY_text_free_code(text);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1734,7 +1734,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
|
|||||||
bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type>>16);
|
bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type>>16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(BPY_eval_button(C, str_unit_convert, &value)) {
|
if(BPY_button_exec(C, str_unit_convert, &value)) {
|
||||||
value = ui_get_but_val(but); /* use its original value */
|
value = ui_get_but_val(but); /* use its original value */
|
||||||
|
|
||||||
if(str[0])
|
if(str[0])
|
||||||
|
@@ -47,7 +47,7 @@
|
|||||||
#include "script_intern.h" // own include
|
#include "script_intern.h" // own include
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
#include "BPY_extern.h" /* BPY_run_python_script */
|
#include "BPY_extern.h" /* BPY_script_exec */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int run_pyfile_exec(bContext *C, wmOperator *op)
|
static int run_pyfile_exec(bContext *C, wmOperator *op)
|
||||||
@@ -55,7 +55,7 @@ static int run_pyfile_exec(bContext *C, wmOperator *op)
|
|||||||
char path[512];
|
char path[512];
|
||||||
RNA_string_get(op->ptr, "filepath", path);
|
RNA_string_get(op->ptr, "filepath", path);
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
if(BPY_run_python_script(C, path, NULL, op->reports)) {
|
if(BPY_filepath_exec(C, path, op->reports)) {
|
||||||
ARegion *ar= CTX_wm_region(C);
|
ARegion *ar= CTX_wm_region(C);
|
||||||
ED_region_tag_redraw(ar);
|
ED_region_tag_redraw(ar);
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
@@ -88,7 +88,7 @@ static int script_reload_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
/* TODO, this crashes on netrender and keying sets, need to look into why
|
/* TODO, this crashes on netrender and keying sets, need to look into why
|
||||||
* disable for now unless running in debug mode */
|
* disable for now unless running in debug mode */
|
||||||
WM_cursor_wait(1);
|
WM_cursor_wait(1);
|
||||||
BPY_eval_string(C, "__import__('bpy').utils.load_scripts(reload_scripts=True)");
|
BPY_string_exec(C, "__import__('bpy').utils.load_scripts(reload_scripts=True)");
|
||||||
WM_cursor_wait(0);
|
WM_cursor_wait(0);
|
||||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
|
@@ -148,12 +148,11 @@ static void script_main_area_draw(const bContext *C, ARegion *ar)
|
|||||||
UI_view2d_view_ortho(v2d);
|
UI_view2d_view_ortho(v2d);
|
||||||
|
|
||||||
/* data... */
|
/* data... */
|
||||||
// BPY_run_python_script(C, "/root/blender-svn/blender25/test.py", NULL);
|
// BPY_script_exec(C, "/root/blender-svn/blender25/test.py", NULL);
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
if (sscript->script) {
|
if (sscript->script) {
|
||||||
//BPY_run_python_script_space(scpt->script.filename, NULL);
|
// BPY_run_script_space_draw(C, sscript);
|
||||||
BPY_run_script_space_draw(C, sscript);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void)sscript;
|
(void)sscript;
|
||||||
|
@@ -314,7 +314,7 @@ static int reload_exec(bContext *C, wmOperator *op)
|
|||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
if(text->compiled)
|
if(text->compiled)
|
||||||
BPY_free_compiled_text(text);
|
BPY_text_free_code(text);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
text_update_edited(text);
|
text_update_edited(text);
|
||||||
@@ -569,7 +569,7 @@ static int run_script_exec(bContext *C, wmOperator *op)
|
|||||||
Text *text= CTX_data_edit_text(C);
|
Text *text= CTX_data_edit_text(C);
|
||||||
SpaceText *st= CTX_wm_space_text(C);
|
SpaceText *st= CTX_wm_space_text(C);
|
||||||
|
|
||||||
if (BPY_run_python_script(C, NULL, text, op->reports))
|
if (BPY_text_exec(C, text, op->reports))
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
|
|
||||||
/* Dont report error messages while live editing */
|
/* Dont report error messages while live editing */
|
||||||
|
@@ -38,14 +38,12 @@ struct Object; /* DNA_object_types.h */
|
|||||||
struct ChannelDriver; /* DNA_anim_types.h */
|
struct ChannelDriver; /* DNA_anim_types.h */
|
||||||
struct ListBase; /* DNA_listBase.h */
|
struct ListBase; /* DNA_listBase.h */
|
||||||
struct SpaceText; /* DNA_space_types.h */
|
struct SpaceText; /* DNA_space_types.h */
|
||||||
struct SpaceScript; /* DNA_space_types.h */
|
|
||||||
struct ScrArea; /* DNA_screen_types.h */
|
struct ScrArea; /* DNA_screen_types.h */
|
||||||
struct bScreen; /* DNA_screen_types.h */
|
struct bScreen; /* DNA_screen_types.h */
|
||||||
struct bConstraint; /* DNA_constraint_types.h */
|
struct bConstraint; /* DNA_constraint_types.h */
|
||||||
struct bPythonConstraint; /* DNA_constraint_types.h */
|
struct bPythonConstraint; /* DNA_constraint_types.h */
|
||||||
struct bConstraintOb; /* DNA_constraint_types.h */
|
struct bConstraintOb; /* DNA_constraint_types.h */
|
||||||
struct bConstraintTarget; /* DNA_constraint_types.h*/
|
struct bConstraintTarget; /* DNA_constraint_types.h*/
|
||||||
struct Script; /* DNA_screen_types.h */
|
|
||||||
struct BPyMenu;
|
struct BPyMenu;
|
||||||
struct bContext;
|
struct bContext;
|
||||||
struct bContextDataResult;
|
struct bContextDataResult;
|
||||||
@@ -55,34 +53,15 @@ struct ReportList;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*These two next functions are important for making sure the Draw module
|
void BPY_pyconstraint_exec(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets);
|
||||||
works correctly. Before calling any gui callback using the Draw module,
|
|
||||||
the following code must be executed:
|
|
||||||
|
|
||||||
if (some_drawspace_pylist) {
|
|
||||||
BPy_Set_DrawButtonsList(some_drawspace_pylist->but_refs);
|
|
||||||
BPy_Free_DrawButtonsList();
|
|
||||||
}
|
|
||||||
some_drawspace_pylist = PyList_New(0);
|
|
||||||
BPy_Set_DrawButtonsList(some_drawspace_pylist);
|
|
||||||
|
|
||||||
Also, BPy_Free_DrawButtonsList() must be called as necassary when a drawspace
|
|
||||||
with python callbacks is destroyed.
|
|
||||||
|
|
||||||
This is necassary to avoid blender buttons storing invalid pointers to freed
|
|
||||||
python data.*/
|
|
||||||
// void BPy_Set_DrawButtonsList(void *list);
|
|
||||||
// void BPy_Free_DrawButtonsList(void);
|
|
||||||
//
|
|
||||||
void BPY_pyconstraint_eval(struct bPythonConstraint *con, struct bConstraintOb *cob, struct ListBase *targets);
|
|
||||||
// void BPY_pyconstraint_settings(void *arg1, void *arg2);
|
// void BPY_pyconstraint_settings(void *arg1, void *arg2);
|
||||||
void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct);
|
void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct);
|
||||||
void BPY_pyconstraint_update(struct Object *owner, struct bConstraint *con);
|
void BPY_pyconstraint_update(struct Object *owner, struct bConstraint *con);
|
||||||
int BPY_is_pyconstraint(struct Text *text);
|
int BPY_is_pyconstraint(struct Text *text);
|
||||||
// void BPY_free_pyconstraint_links(struct Text *text);
|
// void BPY_free_pyconstraint_links(struct Text *text);
|
||||||
//
|
//
|
||||||
void BPY_start_python( int argc, char **argv );
|
void BPY_python_start( int argc, char **argv );
|
||||||
void BPY_end_python( void );
|
void BPY_python_end( void );
|
||||||
// void init_syspath( int first_time );
|
// void init_syspath( int first_time );
|
||||||
// void syspath_append( char *dir );
|
// void syspath_append( char *dir );
|
||||||
// void BPY_rebuild_syspath( void );
|
// void BPY_rebuild_syspath( void );
|
||||||
@@ -90,55 +69,23 @@ extern "C" {
|
|||||||
//
|
//
|
||||||
// int BPY_Err_getLinenumber( void );
|
// int BPY_Err_getLinenumber( void );
|
||||||
// const char *BPY_Err_getFilename( void );
|
// const char *BPY_Err_getFilename( void );
|
||||||
//
|
|
||||||
// int BPY_txt_do_python_Text( struct Text *text );
|
|
||||||
// int BPY_menu_do_python( short menutype, int event );
|
|
||||||
// int BPY_menu_do_shortcut( short menutype, unsigned short key, unsigned short modifiers );
|
|
||||||
// int BPY_menu_invoke( struct BPyMenu *pym, short menutype );
|
|
||||||
|
|
||||||
/* 2.5 UI Scripts */
|
|
||||||
int BPY_run_python_script( struct bContext *C, const char *filename, struct Text *text, struct ReportList *reports ); // 2.5 working
|
|
||||||
int BPY_run_script_space_draw(const struct bContext *C, struct SpaceScript * sc); // 2.5 working
|
|
||||||
// int BPY_run_script_space_listener(struct bContext *C, struct SpaceScript * sc, struct ARegion *ar, struct wmNotifier *wmn); // 2.5 working
|
|
||||||
void BPY_update_modules(struct bContext *C); // XXX - annoying, need this for pointers that get out of date
|
|
||||||
//
|
|
||||||
int BPY_context_get(struct bContext *C, const char *member, struct bContextDataResult *result);
|
|
||||||
//
|
|
||||||
// int BPY_run_script(struct Script *script);
|
|
||||||
void BPY_free_compiled_text( struct Text *text );
|
|
||||||
//
|
|
||||||
// int BPY_has_onload_script( void );
|
|
||||||
//
|
|
||||||
// int BPY_is_spacehandler(struct Text *text, char spacetype);
|
|
||||||
// int BPY_del_spacehandler(struct Text *text, struct ScrArea *sa);
|
|
||||||
// int BPY_add_spacehandler(struct Text *txt, struct ScrArea *sa,char spacetype);
|
|
||||||
// int BPY_has_spacehandler(struct Text *text, struct ScrArea *sa);
|
|
||||||
// void BPY_screen_free_spacehandlers(struct bScreen *sc);
|
|
||||||
// int BPY_do_spacehandlers(struct ScrArea *sa, unsigned short event,
|
|
||||||
// short eventValue, unsigned short space_event);
|
|
||||||
//
|
|
||||||
void BPY_reset_driver(void);
|
|
||||||
float BPY_eval_driver(struct ChannelDriver *driver);
|
|
||||||
//
|
|
||||||
int BPY_eval_button(struct bContext *C, const char *expr, double *value);
|
|
||||||
|
|
||||||
int BPY_eval_string(struct bContext *C, const char *expr);
|
/* 2.5 UI Scripts */
|
||||||
|
int BPY_filepath_exec(struct bContext *C, const char *filepath, struct ReportList *reports);
|
||||||
|
int BPY_text_exec(struct bContext *C, struct Text *text, struct ReportList *reports);
|
||||||
|
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);
|
||||||
|
|
||||||
/* format importer hook */
|
void BPY_driver_reset(void);
|
||||||
int BPY_call_importloader(const char *name);
|
float BPY_driver_exec(struct ChannelDriver *driver);
|
||||||
//
|
|
||||||
// void BPY_spacescript_do_pywin_draw( struct SpaceScript *sc );
|
int BPY_button_exec(struct bContext *C, const char *expr, double *value);
|
||||||
// void BPY_spacescript_do_pywin_event( struct SpaceScript *sc,
|
int BPY_string_exec(struct bContext *C, const char *expr);
|
||||||
// unsigned short event, short val, char ascii );
|
|
||||||
// void BPY_free_finished_script( struct Script *script );
|
void BPY_DECREF(void *pyob_ptr); /* Py_DECREF() */
|
||||||
// void BPY_scripts_clear_pyobjects( void );
|
int BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result);
|
||||||
//
|
void BPY_context_set(struct bContext *C);
|
||||||
// void error_pyscript( void );
|
|
||||||
void BPY_DECREF(void *pyob_ptr); /* Py_DECREF() */
|
|
||||||
void BPY_set_context(struct bContext *C);
|
|
||||||
/* void BPY_Err_Handle(struct Text *text); */
|
|
||||||
/* int BPY_spacetext_is_pywin(struct SpaceText *st); */
|
|
||||||
void BPY_load_user_modules(struct bContext *C);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@@ -69,41 +69,15 @@ int bpy_pydriver_create_dict(void)
|
|||||||
Py_DECREF(mod);
|
Py_DECREF(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0 // non existant yet
|
|
||||||
mod = PyImport_ImportModule("Blender.Noise");
|
|
||||||
if (mod) {
|
|
||||||
PyDict_SetItemString(d, "noise", mod);
|
|
||||||
PyDict_SetItemString(d, "n", mod);
|
|
||||||
Py_DECREF(mod);
|
|
||||||
} else {
|
|
||||||
PyErr_Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If there's a Blender text called pydrivers.py, import it.
|
|
||||||
* Users can add their own functions to this module.
|
|
||||||
*/
|
|
||||||
if (G.f & G_SCRIPT_AUTOEXEC) {
|
|
||||||
mod = importText("pydrivers"); /* can also use PyImport_Import() */
|
|
||||||
if (mod) {
|
|
||||||
PyDict_SetItemString(d, "pydrivers", mod);
|
|
||||||
PyDict_SetItemString(d, "p", mod);
|
|
||||||
Py_DECREF(mod);
|
|
||||||
} else {
|
|
||||||
PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // non existant yet
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update function, it gets rid of pydrivers global dictionary, forcing
|
/* Update function, it gets rid of pydrivers global dictionary, forcing
|
||||||
* BPY_eval_driver to recreate it. This function is used to force
|
* BPY_driver_exec to recreate it. This function is used to force
|
||||||
* reloading the Blender text module "pydrivers.py", if available, so
|
* reloading the Blender text module "pydrivers.py", if available, so
|
||||||
* updates in it reach pydriver evaluation.
|
* updates in it reach pydriver evaluation.
|
||||||
*/
|
*/
|
||||||
void BPY_reset_driver(void)
|
void BPY_driver_reset(void)
|
||||||
{
|
{
|
||||||
PyGILState_STATE gilstate;
|
PyGILState_STATE gilstate;
|
||||||
int use_gil= 1; // (PyThreadState_Get()==NULL);
|
int use_gil= 1; // (PyThreadState_Get()==NULL);
|
||||||
@@ -141,7 +115,7 @@ static void pydriver_error(ChannelDriver *driver)
|
|||||||
* bake operator which intern starts a thread which calls scene update which
|
* bake operator which intern starts a thread which calls scene update which
|
||||||
* does a driver update. to avoid a deadlock check PyThreadState_Get() if PyGILState_Ensure() is needed.
|
* does a driver update. to avoid a deadlock check PyThreadState_Get() if PyGILState_Ensure() is needed.
|
||||||
*/
|
*/
|
||||||
float BPY_eval_driver (ChannelDriver *driver)
|
float BPY_driver_exec(ChannelDriver *driver)
|
||||||
{
|
{
|
||||||
PyObject *driver_vars=NULL;
|
PyObject *driver_vars=NULL;
|
||||||
PyObject *retval= NULL;
|
PyObject *retval= NULL;
|
||||||
@@ -234,11 +208,11 @@ float BPY_eval_driver (ChannelDriver *driver)
|
|||||||
/* this target failed - bad name */
|
/* this target failed - bad name */
|
||||||
if (targets_ok) {
|
if (targets_ok) {
|
||||||
/* first one - print some extra info for easier identification */
|
/* first one - print some extra info for easier identification */
|
||||||
fprintf(stderr, "\nBPY_eval_driver() - Error while evaluating PyDriver:\n");
|
fprintf(stderr, "\nBPY_driver_eval() - Error while evaluating PyDriver:\n");
|
||||||
targets_ok= 0;
|
targets_ok= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "\tBPY_eval_driver() - couldn't add variable '%s' to namespace\n", dvar->name);
|
fprintf(stderr, "\tBPY_driver_eval() - couldn't add variable '%s' to namespace\n", dvar->name);
|
||||||
// BPy_errors_to_report(NULL); // TODO - reports
|
// BPy_errors_to_report(NULL); // TODO - reports
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
@@ -278,7 +252,7 @@ float BPY_eval_driver (ChannelDriver *driver)
|
|||||||
return (float)result;
|
return (float)result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "\tBPY_eval_driver() - driver '%s' evaluates to '%f'\n", dvar->name, result);
|
fprintf(stderr, "\tBPY_driver_eval() - driver '%s' evaluates to '%f'\n", dvar->name, result);
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -88,7 +88,7 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
|
|||||||
fprintf(stderr, "ERROR: Python context called with a NULL Context. this should not happen!\n");
|
fprintf(stderr, "ERROR: Python context called with a NULL Context. this should not happen!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
BPY_update_modules(C); /* can give really bad results if this isnt here */
|
BPY_modules_update(C); /* can give really bad results if this isnt here */
|
||||||
|
|
||||||
#ifdef TIME_PY_RUN
|
#ifdef TIME_PY_RUN
|
||||||
if(bpy_timer_count==0) {
|
if(bpy_timer_count==0) {
|
||||||
@@ -128,7 +128,7 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BPY_free_compiled_text( struct Text *text )
|
void BPY_text_free_code(Text *text)
|
||||||
{
|
{
|
||||||
if( text->compiled ) {
|
if( text->compiled ) {
|
||||||
Py_DECREF( ( PyObject * ) text->compiled );
|
Py_DECREF( ( PyObject * ) text->compiled );
|
||||||
@@ -136,7 +136,7 @@ void BPY_free_compiled_text( struct Text *text )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BPY_update_modules(bContext *C)
|
void BPY_modules_update(bContext *C)
|
||||||
{
|
{
|
||||||
#if 0 // slow, this runs all the time poll, draw etc 100's of time a sec.
|
#if 0 // slow, this runs all the time poll, draw etc 100's of time a sec.
|
||||||
PyObject *mod= PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
|
PyObject *mod= PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
|
||||||
@@ -150,7 +150,7 @@ void BPY_update_modules(bContext *C)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* must be called before Py_Initialize */
|
/* must be called before Py_Initialize */
|
||||||
void BPY_start_python_path(void)
|
void BPY_python_start_path(void)
|
||||||
{
|
{
|
||||||
char *py_path_bundle= BLI_get_folder(BLENDER_PYTHON, NULL);
|
char *py_path_bundle= BLI_get_folder(BLENDER_PYTHON, NULL);
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ void BPY_start_python_path(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void BPY_set_context(bContext *C)
|
void BPY_context_set(bContext *C)
|
||||||
{
|
{
|
||||||
BPy_SetContext(C);
|
BPy_SetContext(C);
|
||||||
}
|
}
|
||||||
@@ -214,8 +214,8 @@ static struct _inittab bpy_internal_modules[]= {
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* call BPY_set_context first */
|
/* call BPY_context_set first */
|
||||||
void BPY_start_python( int argc, char **argv )
|
void BPY_python_start( int argc, char **argv )
|
||||||
{
|
{
|
||||||
PyThreadState *py_tstate = NULL;
|
PyThreadState *py_tstate = NULL;
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ void BPY_start_python( int argc, char **argv )
|
|||||||
/* builtin modules */
|
/* builtin modules */
|
||||||
PyImport_ExtendInittab(bpy_internal_modules);
|
PyImport_ExtendInittab(bpy_internal_modules);
|
||||||
|
|
||||||
BPY_start_python_path(); /* allow to use our own included python */
|
BPY_python_start_path(); /* allow to use our own included python */
|
||||||
|
|
||||||
Py_Initialize( );
|
Py_Initialize( );
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ void BPY_start_python( int argc, char **argv )
|
|||||||
PyEval_ReleaseThread(py_tstate);
|
PyEval_ReleaseThread(py_tstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BPY_end_python( void )
|
void BPY_python_end(void)
|
||||||
{
|
{
|
||||||
// fprintf(stderr, "Ending Python!\n");
|
// fprintf(stderr, "Ending Python!\n");
|
||||||
|
|
||||||
@@ -312,12 +312,13 @@ void BPY_end_python( void )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Can run a file or text block */
|
static int python_script_exec(bContext *C, const char *fn, struct Text *text, struct ReportList *reports)
|
||||||
int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struct ReportList *reports)
|
|
||||||
{
|
{
|
||||||
PyObject *py_dict= NULL, *py_result= NULL;
|
PyObject *py_dict= NULL, *py_result= NULL;
|
||||||
PyGILState_STATE gilstate;
|
PyGILState_STATE gilstate;
|
||||||
|
|
||||||
|
BKE_assert(fn || text);
|
||||||
|
|
||||||
if (fn==NULL && text==NULL) {
|
if (fn==NULL && text==NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -327,7 +328,7 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc
|
|||||||
if (text) {
|
if (text) {
|
||||||
char fn_dummy[FILE_MAXDIR];
|
char fn_dummy[FILE_MAXDIR];
|
||||||
bpy_text_filename_get(fn_dummy, text);
|
bpy_text_filename_get(fn_dummy, text);
|
||||||
|
|
||||||
if( !text->compiled ) { /* if it wasn't already compiled, do it now */
|
if( !text->compiled ) { /* if it wasn't already compiled, do it now */
|
||||||
char *buf = txt_to_buf( text );
|
char *buf = txt_to_buf( text );
|
||||||
|
|
||||||
@@ -336,8 +337,8 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc
|
|||||||
|
|
||||||
MEM_freeN( buf );
|
MEM_freeN( buf );
|
||||||
|
|
||||||
if( PyErr_Occurred( ) ) {
|
if(PyErr_Occurred()) {
|
||||||
BPY_free_compiled_text( text );
|
BPY_text_free_code(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +346,7 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc
|
|||||||
py_dict = PyC_DefaultNameSpace(fn_dummy);
|
py_dict = PyC_DefaultNameSpace(fn_dummy);
|
||||||
py_result = PyEval_EvalCode(text->compiled, py_dict, py_dict);
|
py_result = PyEval_EvalCode(text->compiled, py_dict, py_dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FILE *fp= fopen(fn, "r");
|
FILE *fp= fopen(fn, "r");
|
||||||
@@ -354,9 +355,9 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc
|
|||||||
py_dict = PyC_DefaultNameSpace(fn);
|
py_dict = PyC_DefaultNameSpace(fn);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* Previously we used PyRun_File to run directly the code on a FILE
|
/* Previously we used PyRun_File to run directly the code on a FILE
|
||||||
* object, but as written in the Python/C API Ref Manual, chapter 2,
|
* object, but as written in the Python/C API Ref Manual, chapter 2,
|
||||||
* 'FILE structs for different C libraries can be different and
|
* 'FILE structs for different C libraries can be different and
|
||||||
* incompatible'.
|
* incompatible'.
|
||||||
* So now we load the script file data to a buffer */
|
* So now we load the script file data to a buffer */
|
||||||
{
|
{
|
||||||
@@ -380,14 +381,14 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc
|
|||||||
py_result= NULL;
|
py_result= NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!py_result) {
|
if (!py_result) {
|
||||||
BPy_errors_to_report(reports);
|
BPy_errors_to_report(reports);
|
||||||
} else {
|
} else {
|
||||||
Py_DECREF( py_result );
|
Py_DECREF( py_result );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* super annoying, undo _PyModule_Clear() */
|
/* super annoying, undo _PyModule_Clear() */
|
||||||
#define PYMODULE_CLEAR_WORKAROUND
|
#define PYMODULE_CLEAR_WORKAROUND
|
||||||
|
|
||||||
if(py_dict) {
|
if(py_dict) {
|
||||||
@@ -405,92 +406,22 @@ int BPY_run_python_script( bContext *C, const char *fn, struct Text *text, struc
|
|||||||
#endif
|
#endif
|
||||||
#undef PYMODULE_CLEAR_WORKAROUND
|
#undef PYMODULE_CLEAR_WORKAROUND
|
||||||
}
|
}
|
||||||
|
|
||||||
bpy_context_clear(C, &gilstate);
|
bpy_context_clear(C, &gilstate);
|
||||||
|
|
||||||
return py_result ? 1:0;
|
return (py_result != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Can run a file or text block */
|
||||||
|
int BPY_filepath_exec(bContext *C, const char *filepath, struct ReportList *reports)
|
||||||
|
{
|
||||||
|
return python_script_exec(C, filepath, NULL, reports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO - move into bpy_space.c ? */
|
int BPY_text_exec(bContext *C, struct Text *text, struct ReportList *reports)
|
||||||
/* GUI interface routines */
|
|
||||||
|
|
||||||
/* Copied from Draw.c */
|
|
||||||
static void exit_pydraw( SpaceScript * sc, short err )
|
|
||||||
{
|
{
|
||||||
Script *script = NULL;
|
return python_script_exec(C, NULL, text, reports);
|
||||||
|
|
||||||
if( !sc || !sc->script )
|
|
||||||
return;
|
|
||||||
|
|
||||||
script = sc->script;
|
|
||||||
|
|
||||||
if( err ) {
|
|
||||||
BPy_errors_to_report(NULL); // TODO, reports
|
|
||||||
script->flags = 0; /* mark script struct for deletion */
|
|
||||||
SCRIPT_SET_NULL(script);
|
|
||||||
script->scriptname[0] = '\0';
|
|
||||||
script->scriptarg[0] = '\0';
|
|
||||||
// XXX 2.5 error_pyscript();
|
|
||||||
// XXX 2.5 scrarea_queue_redraw( sc->area );
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0 // XXX 2.5
|
|
||||||
BPy_Set_DrawButtonsList(sc->but_refs);
|
|
||||||
BPy_Free_DrawButtonsList(); /*clear all temp button references*/
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sc->but_refs = NULL;
|
|
||||||
|
|
||||||
Py_XDECREF( ( PyObject * ) script->py_draw );
|
|
||||||
Py_XDECREF( ( PyObject * ) script->py_event );
|
|
||||||
Py_XDECREF( ( PyObject * ) script->py_button );
|
|
||||||
|
|
||||||
script->py_draw = script->py_event = script->py_button = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int bpy_run_script_init(bContext *C, SpaceScript * sc)
|
|
||||||
{
|
|
||||||
if (sc->script==NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (sc->script->py_draw==NULL && sc->script->scriptname[0] != '\0')
|
|
||||||
BPY_run_python_script(C, sc->script->scriptname, NULL, NULL);
|
|
||||||
|
|
||||||
if (sc->script->py_draw==NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int BPY_run_script_space_draw(const struct bContext *C, SpaceScript * sc)
|
|
||||||
{
|
|
||||||
if (bpy_run_script_init( (bContext *)C, sc)) {
|
|
||||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
|
||||||
PyObject *result = PyObject_CallObject( sc->script->py_draw, NULL );
|
|
||||||
|
|
||||||
if (result==NULL)
|
|
||||||
exit_pydraw(sc, 1);
|
|
||||||
|
|
||||||
PyGILState_Release(gilstate);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX - not used yet, listeners dont get a context
|
|
||||||
int BPY_run_script_space_listener(bContext *C, SpaceScript * sc)
|
|
||||||
{
|
|
||||||
if (bpy_run_script_init(C, sc)) {
|
|
||||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
|
||||||
|
|
||||||
PyObject *result = PyObject_CallObject( sc->script->py_draw, NULL );
|
|
||||||
|
|
||||||
if (result==NULL)
|
|
||||||
exit_pydraw(sc, 1);
|
|
||||||
|
|
||||||
PyGILState_Release(gilstate);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BPY_DECREF(void *pyob_ptr)
|
void BPY_DECREF(void *pyob_ptr)
|
||||||
@@ -500,57 +431,7 @@ void BPY_DECREF(void *pyob_ptr)
|
|||||||
PyGILState_Release(gilstate);
|
PyGILState_Release(gilstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
int BPY_button_exec(bContext *C, const char *expr, double *value)
|
||||||
/* called from the the scripts window, assume context is ok */
|
|
||||||
int BPY_run_python_script_space(const char *modulename, const char *func)
|
|
||||||
{
|
|
||||||
PyObject *py_dict, *py_result= NULL;
|
|
||||||
char pystring[512];
|
|
||||||
PyGILState_STATE gilstate;
|
|
||||||
|
|
||||||
/* for calling the module function */
|
|
||||||
PyObject *py_func,
|
|
||||||
|
|
||||||
gilstate = PyGILState_Ensure();
|
|
||||||
|
|
||||||
py_dict = PyC_DefaultNameSpace("<dummy>");
|
|
||||||
|
|
||||||
PyObject *module = PyImport_ImportModule(scpt->script.filename);
|
|
||||||
if (module==NULL) {
|
|
||||||
PyErr_SetFormat(PyExc_SystemError, "could not import '%s'", scpt->script.filename);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
py_func = PyObject_GetAttrString(modulename, func);
|
|
||||||
if (py_func==NULL) {
|
|
||||||
PyErr_SetFormat(PyExc_SystemError, "module has no function '%s.%s'\n", scpt->script.filename, func);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Py_DECREF(py_func);
|
|
||||||
if (!PyCallable_Check(py_func)) {
|
|
||||||
PyErr_SetFormat(PyExc_SystemError, "module item is not callable '%s.%s'\n", scpt->script.filename, func);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
py_result= PyObject_CallObject(py_func, NULL); // XXX will need args eventually
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!py_result) {
|
|
||||||
BPy_errors_to_report(NULL); // TODO - reports
|
|
||||||
} else
|
|
||||||
Py_DECREF( py_result );
|
|
||||||
|
|
||||||
Py_XDECREF(module);
|
|
||||||
|
|
||||||
PyDict_SetItemString(PyThreadState_GET()->interp->modules, "__main__", Py_None);
|
|
||||||
|
|
||||||
PyGILState_Release(gilstate);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
int BPY_eval_button(bContext *C, const char *expr, double *value)
|
|
||||||
{
|
{
|
||||||
PyGILState_STATE gilstate;
|
PyGILState_STATE gilstate;
|
||||||
PyObject *py_dict, *mod, *retval;
|
PyObject *py_dict, *mod, *retval;
|
||||||
@@ -622,7 +503,7 @@ int BPY_eval_button(bContext *C, const char *expr, double *value)
|
|||||||
return error_ret;
|
return error_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BPY_eval_string(bContext *C, const char *expr)
|
int BPY_string_exec(bContext *C, const char *expr)
|
||||||
{
|
{
|
||||||
PyGILState_STATE gilstate;
|
PyGILState_STATE gilstate;
|
||||||
PyObject *py_dict, *retval;
|
PyObject *py_dict, *retval;
|
||||||
@@ -657,7 +538,7 @@ int BPY_eval_string(bContext *C, const char *expr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BPY_load_user_modules(bContext *C)
|
void BPY_modules_load_user(bContext *C)
|
||||||
{
|
{
|
||||||
PyGILState_STATE gilstate;
|
PyGILState_STATE gilstate;
|
||||||
Main *bmain= CTX_data_main(C);
|
Main *bmain= CTX_data_main(C);
|
||||||
@@ -690,7 +571,7 @@ void BPY_load_user_modules(bContext *C)
|
|||||||
bpy_context_clear(C, &gilstate);
|
bpy_context_clear(C, &gilstate);
|
||||||
}
|
}
|
||||||
|
|
||||||
int BPY_context_get(bContext *C, const char *member, bContextDataResult *result)
|
int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *result)
|
||||||
{
|
{
|
||||||
PyObject *pyctx= (PyObject *)CTX_py_dict_get(C);
|
PyObject *pyctx= (PyObject *)CTX_py_dict_get(C);
|
||||||
PyObject *item= PyDict_GetItemString(pyctx, member);
|
PyObject *item= PyDict_GetItemString(pyctx, member);
|
||||||
|
@@ -5176,7 +5176,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void BPY_update_modules(bContext *C); //XXX temp solution
|
extern void BPY_modules_update(bContext *C); //XXX temp solution
|
||||||
|
|
||||||
/* TODO - multiple return values like with rna functions */
|
/* TODO - multiple return values like with rna functions */
|
||||||
static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
|
static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
|
||||||
|
@@ -27,11 +27,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* python, will come back */
|
/* python, will come back */
|
||||||
//void BPY_run_python_script(void) {}
|
//void BPY_script_exec(void) {}
|
||||||
//void BPY_start_python(void) {}
|
//void BPY_python_start(void) {}
|
||||||
void BPY_call_importloader(const char *filepath) {(void)filepath;}
|
//void BPY_text_free_code(void) {}
|
||||||
//void BPY_free_compiled_text(void) {}
|
void BPY_pyconstraint_exec(void) {}
|
||||||
void BPY_pyconstraint_eval(void) {}
|
|
||||||
void BPY_pyconstraint_target(void) {}
|
void BPY_pyconstraint_target(void) {}
|
||||||
int BPY_is_pyconstraint(void) {return 0;}
|
int BPY_is_pyconstraint(void) {return 0;}
|
||||||
void BPY_pyconstraint_update(void) {}
|
void BPY_pyconstraint_update(void) {}
|
||||||
|
@@ -316,8 +316,8 @@ void WM_read_file(bContext *C, const char *name, ReportList *reports)
|
|||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
/* run any texts that were loaded in and flagged as modules */
|
/* run any texts that were loaded in and flagged as modules */
|
||||||
BPY_reset_driver();
|
BPY_driver_reset();
|
||||||
BPY_load_user_modules(C);
|
BPY_modules_load_user(C);
|
||||||
#endif
|
#endif
|
||||||
CTX_wm_window_set(C, NULL); /* exits queues */
|
CTX_wm_window_set(C, NULL); /* exits queues */
|
||||||
|
|
||||||
@@ -415,10 +415,10 @@ int WM_read_homefile(bContext *C, wmOperator *op)
|
|||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
if(CTX_py_init_get(C)) {
|
if(CTX_py_init_get(C)) {
|
||||||
/* sync addons, these may have changed from the defaults */
|
/* sync addons, these may have changed from the defaults */
|
||||||
BPY_eval_string(C, "__import__('bpy').utils.addon_reset_all()");
|
BPY_string_exec(C, "__import__('bpy').utils.addon_reset_all()");
|
||||||
|
|
||||||
BPY_reset_driver();
|
BPY_driver_reset();
|
||||||
BPY_load_user_modules(C);
|
BPY_modules_load_user(C);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -144,11 +144,11 @@ void WM_init(bContext *C, int argc, char **argv)
|
|||||||
* Will try fix when the crash can be repeated. - campbell. */
|
* Will try fix when the crash can be repeated. - campbell. */
|
||||||
|
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
BPY_set_context(C); /* necessary evil */
|
BPY_context_set(C); /* necessary evil */
|
||||||
BPY_start_python(argc, argv);
|
BPY_python_start(argc, argv);
|
||||||
|
|
||||||
BPY_reset_driver();
|
BPY_driver_reset();
|
||||||
BPY_load_user_modules(C);
|
BPY_modules_load_user(C);
|
||||||
#else
|
#else
|
||||||
(void)argc; /* unused */
|
(void)argc; /* unused */
|
||||||
(void)argv; /* unused */
|
(void)argv; /* unused */
|
||||||
@@ -412,7 +412,7 @@ void WM_exit(bContext *C)
|
|||||||
/* Update for blender 2.5, move after free_blender because blender now holds references to PyObject's
|
/* Update for blender 2.5, move after free_blender because blender now holds references to PyObject's
|
||||||
* so decref'ing them after python ends causes bad problems every time
|
* so decref'ing them after python ends causes bad problems every time
|
||||||
* the pyDriver bug can be fixed if it happens again we can deal with it then */
|
* the pyDriver bug can be fixed if it happens again we can deal with it then */
|
||||||
BPY_end_python();
|
BPY_python_end();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!G.background) {
|
if (!G.background) {
|
||||||
@@ -435,7 +435,7 @@ void WM_exit(bContext *C)
|
|||||||
UI_exit();
|
UI_exit();
|
||||||
BKE_userdef_free();
|
BKE_userdef_free();
|
||||||
|
|
||||||
RNA_exit(); /* should be after BPY_end_python so struct python slots are cleared */
|
RNA_exit(); /* should be after BPY_python_end so struct python slots are cleared */
|
||||||
|
|
||||||
wm_ghost_exit();
|
wm_ghost_exit();
|
||||||
|
|
||||||
|
@@ -556,7 +556,7 @@ endif()
|
|||||||
ge_scenegraph
|
ge_scenegraph
|
||||||
ge_logic_network
|
ge_logic_network
|
||||||
bf_gen_system
|
bf_gen_system
|
||||||
bf_python # duplicate for BPY_eval_driver
|
bf_python # duplicate for BPY_driver_exec
|
||||||
ge_logic_ngnetwork
|
ge_logic_ngnetwork
|
||||||
extern_bullet
|
extern_bullet
|
||||||
ge_logic_loopbacknetwork
|
ge_logic_loopbacknetwork
|
||||||
|
@@ -861,7 +861,7 @@ static int run_python(int argc, char **argv, void *data)
|
|||||||
BLI_strncpy(filename, argv[1], sizeof(filename));
|
BLI_strncpy(filename, argv[1], sizeof(filename));
|
||||||
BLI_path_cwd(filename);
|
BLI_path_cwd(filename);
|
||||||
|
|
||||||
BPY_CTX_SETUP( BPY_run_python_script(C, filename, NULL, NULL) )
|
BPY_CTX_SETUP(BPY_filepath_exec(C, filename, NULL))
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -878,10 +878,9 @@ static int run_python(int argc, char **argv, void *data)
|
|||||||
static int run_python_console(int UNUSED(argc), char **argv, void *data)
|
static int run_python_console(int UNUSED(argc), char **argv, void *data)
|
||||||
{
|
{
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
bContext *C = data;
|
bContext *C = data;
|
||||||
const char *expr= "__import__('code').interact()";
|
|
||||||
|
|
||||||
BPY_CTX_SETUP( BPY_eval_string(C, expr) )
|
BPY_CTX_SETUP(BPY_string_exec(C, "__import__('code').interact()"))
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
@@ -926,8 +925,8 @@ static int load_file(int UNUSED(argc), char **argv, void *data)
|
|||||||
/* WM_read_file() runs normally but since we're in background mode do here */
|
/* WM_read_file() runs normally but since we're in background mode do here */
|
||||||
#ifdef WITH_PYTHON
|
#ifdef WITH_PYTHON
|
||||||
/* run any texts that were loaded in and flagged as modules */
|
/* run any texts that were loaded in and flagged as modules */
|
||||||
BPY_reset_driver();
|
BPY_driver_reset();
|
||||||
BPY_load_user_modules(C);
|
BPY_modules_load_user(C);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* happens for the UI on file reading too (huh? (ton))*/
|
/* happens for the UI on file reading too (huh? (ton))*/
|
||||||
@@ -1159,7 +1158,7 @@ int main(int argc, char **argv)
|
|||||||
* NOTE: the U.pythondir string is NULL until WM_init() is executed,
|
* NOTE: the U.pythondir string is NULL until WM_init() is executed,
|
||||||
* so we provide the BPY_ function below to append the user defined
|
* so we provide the BPY_ function below to append the user defined
|
||||||
* pythondir to Python's sys.path at this point. Simply putting
|
* pythondir to Python's sys.path at this point. Simply putting
|
||||||
* WM_init() before BPY_start_python() crashes Blender at startup.
|
* WM_init() before BPY_python_start() crashes Blender at startup.
|
||||||
* Update: now this function also inits the bpymenus, which also depend
|
* Update: now this function also inits the bpymenus, which also depend
|
||||||
* on U.pythondir.
|
* on U.pythondir.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user