P.cpp (pymol-open-source-2.2.0) | : | P.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 442 | skipping to change at line 442 | |||
} | } | |||
auto G = wobj->G; | auto G = wobj->G; | |||
if ((setting_id = get_and_check_setting_index(G, key)) == -1) { | if ((setting_id = get_and_check_setting_index(G, key)) == -1) { | |||
return NULL; | return NULL; | |||
} | } | |||
if (wobj->idx >= 0){ | if (wobj->idx >= 0){ | |||
// atom-state level | // atom-state level | |||
// (not supported in Open-Source PyMOL, skip to atom level setting) | ret = SettingGetIfDefinedPyObject(G, wobj->cs, wobj->idx, setting_id); | |||
} | } | |||
if (!ret){ | if (!ret){ | |||
// atom level | // atom level | |||
ret = SettingGetIfDefinedPyObject(G, wobj->atomInfo, setting_id); | ret = SettingGetIfDefinedPyObject(G, wobj->atomInfo, setting_id); | |||
if (!ret) { | if (!ret) { | |||
// object-state, object, or global | // object-state, object, or global | |||
ret = SettingGetPyObject(G, | ret = SettingGetPyObject(G, | |||
wobj->cs ? wobj->cs->Setting : NULL, | wobj->cs ? wobj->cs->Setting : NULL, | |||
skipping to change at line 493 | skipping to change at line 493 | |||
PyErr_SetString(PyExc_TypeError, "Use alter/alter_state to modify settings") ; | PyErr_SetString(PyExc_TypeError, "Use alter/alter_state to modify settings") ; | |||
return -1; | return -1; | |||
} | } | |||
if ((setting_id = get_and_check_setting_index(G, key)) == -1) { | if ((setting_id = get_and_check_setting_index(G, key)) == -1) { | |||
return -1; | return -1; | |||
} | } | |||
if (wobj->idx >= 0) { | if (wobj->idx >= 0) { | |||
// atom-state level | // atom-state level | |||
PyErr_SetString(PyExc_NotImplementedError, | if(!SettingLevelCheck(G, setting_id, cSettingLevel_astate)) { | |||
"atom-state-level settings not supported in Open-Source PyMOL"); | PyErr_SetString(PyExc_TypeError, | |||
return -1; // failure | "only atom-state level settings can be set in alter_state function"); | |||
return -1; // failure | ||||
} else if (CoordSetSetSettingFromPyObject(G, wobj->cs, wobj->idx, setting_id | ||||
, val)) { | ||||
} | ||||
} else { | } else { | |||
// atom level | // atom level | |||
if(!SettingLevelCheck(G, setting_id, cSettingLevel_atom)) { | if(!SettingLevelCheck(G, setting_id, cSettingLevel_atom)) { | |||
PyErr_SetString(PyExc_TypeError, | PyErr_SetString(PyExc_TypeError, | |||
"only atom-level settings can be set in alter function"); | "only atom-level settings can be set in alter function"); | |||
return -1; // failure | return -1; // failure | |||
} else if (AtomInfoSetSettingFromPyObject(G, wobj->atomInfo, setting_id, val )) { | } else if (AtomInfoSetSettingFromPyObject(G, wobj->atomInfo, setting_id, val )) { | |||
AtomInfoSettingGenerateSideEffects(G, wobj->obj, setting_id, wobj->atm); | AtomInfoSettingGenerateSideEffects(G, wobj->obj, setting_id, wobj->atm); | |||
} | } | |||
} | } | |||
skipping to change at line 524 | skipping to change at line 527 | |||
{ | { | |||
auto& wobj = reinterpret_cast<SettingPropertyWrapperObject*>(self)->wobj; | auto& wobj = reinterpret_cast<SettingPropertyWrapperObject*>(self)->wobj; | |||
if (!check_wrapper_scope(wobj)) { | if (!check_wrapper_scope(wobj)) { | |||
return NULL; | return NULL; | |||
} | } | |||
int unique_id = wobj->atomInfo->unique_id; | int unique_id = wobj->atomInfo->unique_id; | |||
if (wobj->idx >= 0) { | if (wobj->idx >= 0) { | |||
PyErr_SetString(PyExc_NotImplementedError, | unique_id = | |||
"atom-state-level settings not supported in Open-Source PyMOL"); | wobj->cs->atom_state_setting_id ? | |||
return NULL; | wobj->cs->atom_state_setting_id[wobj->idx] : 0; | |||
} | } | |||
PyObject * items = SettingUniqueGetIndicesAsPyList(wobj->G, unique_id); | PyObject * items = SettingUniqueGetIndicesAsPyList(wobj->G, unique_id); | |||
PyObject * iter = PyObject_GetIter(items); | PyObject * iter = PyObject_GetIter(items); | |||
Py_XDECREF(items); | Py_XDECREF(items); | |||
return iter; | return iter; | |||
} | } | |||
/* | /* | |||
skipping to change at line 980 | skipping to change at line 983 | |||
static void PUnlockGLUT(PyMOLGlobals * G) | static void PUnlockGLUT(PyMOLGlobals * G) | |||
{ /* assumes we have the GIL */ | { /* assumes we have the GIL */ | |||
PXDecRef(PYOBJECT_CALLFUNCTION(G->P_inst->unlock_glut, "O", G->P_inst->cmd)); | PXDecRef(PYOBJECT_CALLFUNCTION(G->P_inst->unlock_glut, "O", G->P_inst->cmd)); | |||
} | } | |||
static long P_glut_thread_id = -1; | static long P_glut_thread_id = -1; | |||
/* enables us to keep glut out if by chance it grabs the API | /* enables us to keep glut out if by chance it grabs the API | |||
* in the middle of a nested API based operation */ | * in the middle of a nested API based operation */ | |||
static | ||||
void PCatchInit(void); | void PCatchInit(void); | |||
void my_interrupt(int a); | ||||
/* | /* | |||
PyObject *GetBondsDict(PyMOLGlobals *G) | PyObject *GetBondsDict(PyMOLGlobals *G) | |||
{ | { | |||
PyObject *result = NULL; | PyObject *result = NULL; | |||
result = PyObject_GetAttrString(P_chempy,"bonds"); | result = PyObject_GetAttrString(P_chempy,"bonds"); | |||
if(!result) ErrMessage(G,"PyMOL","can't find 'chempy.bonds.bonds'"); | if(!result) ErrMessage(G,"PyMOL","can't find 'chempy.bonds.bonds'"); | |||
return(result); | return(result); | |||
} | } | |||
*/ | */ | |||
skipping to change at line 1108 | skipping to change at line 1111 | |||
obj = Py_None; | obj = Py_None; | |||
Py_XINCREF(obj); | Py_XINCREF(obj); | |||
return obj; | return obj; | |||
} | } | |||
void PXDecRef(PyObject * obj) | void PXDecRef(PyObject * obj) | |||
{ | { | |||
Py_XDECREF(obj); | Py_XDECREF(obj); | |||
} | } | |||
OV_STATIC ov_status CacheCreateEntry(PyObject ** result, PyObject * input) | static ov_status CacheCreateEntry(PyObject ** result, PyObject * input) | |||
{ | { | |||
ov_status status = OV_STATUS_FAILURE; | ov_status status = OV_STATUS_FAILURE; | |||
if(input && PyTuple_Check(input)) { | if(input && PyTuple_Check(input)) { | |||
ov_size tuple_size = PyTuple_Size(input); | ov_size tuple_size = PyTuple_Size(input); | |||
ov_size tot_size = tuple_size; | ov_size tot_size = tuple_size; | |||
PyObject *hash_code = PyTuple_New(tuple_size); | PyObject *hash_code = PyTuple_New(tuple_size); | |||
PyObject *entry = PyList_New(6); | PyObject *entry = PyList_New(6); | |||
if(hash_code && entry) { | if(hash_code && entry) { | |||
/* compute hash codes & total input size */ | /* compute hash codes & total input size */ | |||
ov_size i; | ov_size i; | |||
skipping to change at line 1280 | skipping to change at line 1283 | |||
PXDecRef(PYOBJECT_CALLFUNCTION(P_sleep, "f", usec / 1000000.0)); | PXDecRef(PYOBJECT_CALLFUNCTION(P_sleep, "f", usec / 1000000.0)); | |||
PLockAPIAndUnblock(G); | PLockAPIAndUnblock(G); | |||
/* END PROPRIETARY CODE SEGMENT */ | /* END PROPRIETARY CODE SEGMENT */ | |||
#endif | #endif | |||
} | } | |||
static PyObject *PCatchWrite(PyObject * self, PyObject * args); | static PyObject *PCatchWrite(PyObject * self, PyObject * args); | |||
static PyObject *PCatch_install(PyObject * self, PyObject * args); | static PyObject *PCatch_install(PyObject * self, PyObject * args); | |||
static | ||||
void my_interrupt(int a) | void my_interrupt(int a) | |||
{ | { | |||
exit(EXIT_FAILURE); | exit(EXIT_FAILURE); | |||
} | } | |||
void PDumpTraceback(PyObject * err) | void PDumpTraceback(PyObject * err) | |||
{ | { | |||
PYOBJECT_CALLMETHOD(P_traceback, "print_tb", "O", err); | PYOBJECT_CALLMETHOD(P_traceback, "print_tb", "O", err); | |||
} | } | |||
void PDumpException() | void PDumpException() | |||
{ | { | |||
PYOBJECT_CALLMETHOD(P_traceback, "print_exc", ""); | PYOBJECT_CALLMETHOD(P_traceback, "print_exc", ""); | |||
} | } | |||
static | static | |||
WrapperObject * WrapperObjectNew() { | WrapperObject * WrapperObjectNew() { | |||
auto wobj = (WrapperObject *)PyType_GenericNew(&Wrapper_Type, Py_None, Py_None ); | auto wobj = (WrapperObject *)PyType_GenericNew(&Wrapper_Type, Py_None, Py_None ); | |||
wobj->dict = NULL; | wobj->dict = NULL; | |||
wobj->settingWrapperObject = NULL; | wobj->settingWrapperObject = NULL; | |||
#ifdef _PYMOL_IP_EXTRAS | #ifdef _PYMOL_IP_PROPERTIES | |||
wobj->propertyWrapperObject = NULL; | wobj->propertyWrapperObject = NULL; | |||
#endif | #endif | |||
return wobj; | return wobj; | |||
} | } | |||
int PAlterAtomState(PyMOLGlobals * G, PyCodeObject *expr_co, int read_only, | int PAlterAtomState(PyMOLGlobals * G, PyCodeObject *expr_co, int read_only, | |||
ObjectMolecule *obj, CoordSet *cs, int atm, int idx, | ObjectMolecule *obj, CoordSet *cs, int atm, int idx, | |||
int state, PyObject * space) | int state, PyObject * space) | |||
/* assumes Blocked python interpreter */ | /* assumes Blocked python interpreter */ | |||
skipping to change at line 1606 | skipping to change at line 1610 | |||
void init_pyomm(void); | void init_pyomm(void); | |||
#endif | #endif | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif | #endif | |||
#endif | #endif | |||
/* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ | /* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ | |||
#ifdef WIN32 | #if 0 // def WIN32 | |||
static int IsSecurityRequired() | static int IsSecurityRequired() | |||
{ | { | |||
DWORD WindowsVersion = GetVersion(); | DWORD WindowsVersion = GetVersion(); | |||
DWORD WindowsMajorVersion = (DWORD) (LOBYTE(LOWORD(WindowsVersion))); | DWORD WindowsMajorVersion = (DWORD) (LOBYTE(LOWORD(WindowsVersion))); | |||
DWORD WindowsMinorVersion = (DWORD) (HIBYTE(LOWORD(WindowsVersion))); | DWORD WindowsMinorVersion = (DWORD) (HIBYTE(LOWORD(WindowsVersion))); | |||
if(WindowsVersion >= 0x80000000) | if(WindowsVersion >= 0x80000000) | |||
return FALSE; | return FALSE; | |||
return TRUE; | return TRUE; | |||
skipping to change at line 1628 | skipping to change at line 1632 | |||
#endif | #endif | |||
/* END PROPRIETARY CODE SEGMENT */ | /* END PROPRIETARY CODE SEGMENT */ | |||
void PSetupEmbedded(PyMOLGlobals * G, int argc, char **argv) | void PSetupEmbedded(PyMOLGlobals * G, int argc, char **argv) | |||
{ | { | |||
/* This routine is called if we are running with an embedded Python interprete r */ | /* This routine is called if we are running with an embedded Python interprete r */ | |||
PyObject *args; | PyObject *args; | |||
/* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ | /* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ | |||
#ifdef WIN32 | #if 0 // def WIN32 | |||
/* Windows PyMOL now ships with Python 2.5 for both | /* Windows PyMOL now ships with Python 2.5 for both | |||
32 and 64 bit */ | 32 and 64 bit */ | |||
#ifndef EMBEDDED_PYTHONHOME | #ifndef EMBEDDED_PYTHONHOME | |||
#define EMBEDDED_PYTHONHOME "\\py27" | #define EMBEDDED_PYTHONHOME "\\py27" | |||
#endif | #endif | |||
{ /* Automatically hide the window if this process was started as a | { /* Automatically hide the window if this process was started as a | |||
vanilla console application (by double-clicki ng). | vanilla console application (by double-clicki ng). | |||
skipping to change at line 2094 | skipping to change at line 2098 | |||
void PRunStringInstance(PyMOLGlobals * G, const char *str) | void PRunStringInstance(PyMOLGlobals * G, const char *str) | |||
{ /* runs a string in the namespace of the pymol i nstance */ | { /* runs a string in the namespace of the pymol i nstance */ | |||
PXDecRef(PYOBJECT_CALLFUNCTION(G->P_inst->exec, "Os", G->P_inst->obj, str)); | PXDecRef(PYOBJECT_CALLFUNCTION(G->P_inst->exec, "Os", G->P_inst->obj, str)); | |||
} | } | |||
void WrapperObjectReset(WrapperObject *wo){ | void WrapperObjectReset(WrapperObject *wo){ | |||
if (wo->settingWrapperObject) { | if (wo->settingWrapperObject) { | |||
reinterpret_cast<SettingPropertyWrapperObject *>(wo->settingWrapperObject)-> wobj = NULL; | reinterpret_cast<SettingPropertyWrapperObject *>(wo->settingWrapperObject)-> wobj = NULL; | |||
Py_DECREF(wo->settingWrapperObject); | Py_DECREF(wo->settingWrapperObject); | |||
} | } | |||
#ifdef _PYMOL_IP_EXTRAS | #ifdef _PYMOL_IP_PROPERTIES | |||
if (wo->propertyWrapperObject) { | if (wo->propertyWrapperObject) { | |||
reinterpret_cast<SettingPropertyWrapperObject *>(wo->propertyWrapperObject)- >wobj = NULL; | reinterpret_cast<SettingPropertyWrapperObject *>(wo->propertyWrapperObject)- >wobj = NULL; | |||
Py_DECREF(wo->propertyWrapperObject); | Py_DECREF(wo->propertyWrapperObject); | |||
} | } | |||
#endif | #endif | |||
Py_XDECREF(wo->dict); | Py_XDECREF(wo->dict); | |||
Py_DECREF(wo); | Py_DECREF(wo); | |||
} | } | |||
void PInit(PyMOLGlobals * G, int global_instance) | void PInit(PyMOLGlobals * G, int global_instance) | |||
skipping to change at line 2325 | skipping to change at line 2329 | |||
PBlock(G); | PBlock(G); | |||
result = | result = | |||
PYOBJECT_CALLMETHOD(P_povray, "render_from_string", "sssiii", header, inp, f ile, | PYOBJECT_CALLMETHOD(P_povray, "render_from_string", "sssiii", header, inp, f ile, | |||
width, height, antialias); | width, height, antialias); | |||
ok = PyObject_IsTrue(result); | ok = PyObject_IsTrue(result); | |||
Py_DECREF(result); | Py_DECREF(result); | |||
PUnblock(G); | PUnblock(G); | |||
return (ok); | return (ok); | |||
} | } | |||
void PSGIStereo(PyMOLGlobals * G, int flag) | ||||
{ | ||||
int blocked; | ||||
blocked = PAutoBlock(G); | ||||
if(flag) | ||||
PRunStringModule(G, "cmd._sgi_stereo(1)"); | ||||
else | ||||
PRunStringModule(G, "cmd._sgi_stereo(0)"); | ||||
if(blocked) | ||||
PUnblock(G); | ||||
} | ||||
void PFree(PyMOLGlobals * G) | void PFree(PyMOLGlobals * G) | |||
{ | { | |||
PXDecRef(G->P_inst->parse); | PXDecRef(G->P_inst->parse); | |||
PXDecRef(G->P_inst->complete); | PXDecRef(G->P_inst->complete); | |||
PXDecRef(G->P_inst->colortype); | PXDecRef(G->P_inst->colortype); | |||
} | } | |||
void PExit(PyMOLGlobals * G, int code) | void PExit(PyMOLGlobals * G, int code) | |||
{ | { | |||
ExecutiveDelete(G, "all"); | ExecutiveDelete(G, "all"); | |||
skipping to change at line 2490 | skipping to change at line 2482 | |||
int PFlush(PyMOLGlobals * G) | int PFlush(PyMOLGlobals * G) | |||
{ | { | |||
/* NOTE: ASSUMES unblocked Python threads and a locked API */ | /* NOTE: ASSUMES unblocked Python threads and a locked API */ | |||
PyObject *err; | PyObject *err; | |||
int did_work = false; | int did_work = false; | |||
if(OrthoCommandWaiting(G)) { | if(OrthoCommandWaiting(G)) { | |||
did_work = true; | did_work = true; | |||
PBlock(G); | PBlock(G); | |||
if(!(PIsGlutThread() && G->P_inst->glut_thread_keep_out)) { | if(!(PIsGlutThread() && G->P_inst->glut_thread_keep_out)) { | |||
/* don't run if we're currently banned */ | /* don't run if we're currently banned */ | |||
char *buffer = 0; | auto ortho = G->Ortho; | |||
int size; | while(!OrthoCommandIsEmpty(*ortho)){ | |||
while((size = OrthoCommandOutSize(G))){ | auto buffer = OrthoCommandOut(*ortho); | |||
if (!buffer){ | OrthoCommandSetBusy(G, true); | |||
buffer = VLACalloc(char, size); | ||||
} else { | ||||
VLACheck(buffer, char, size); | ||||
} | ||||
OrthoCommandSetBusy(G, true); | ||||
OrthoCommandOut(G, buffer); | ||||
OrthoCommandNest(G, 1); | OrthoCommandNest(G, 1); | |||
PUnlockAPIWhileBlocked(G); | PUnlockAPIWhileBlocked(G); | |||
if(PyErr_Occurred()) { | if(PyErr_Occurred()) { | |||
PyErr_Print(); | PyErr_Print(); | |||
PRINTFB(G, FB_Python, FB_Errors) | PRINTFB(G, FB_Python, FB_Errors) | |||
" PFlush: Uncaught exception. PyMOL may have a bug.\n" ENDFB(G); | " PFlush: Uncaught exception. PyMOL may have a bug.\n" ENDFB(G); | |||
} | } | |||
PXDecRef(PYOBJECT_CALLFUNCTION(G->P_inst->parse, "si", buffer, 0)); | PXDecRef(PYOBJECT_CALLFUNCTION(G->P_inst->parse, "si", buffer.c_str(), 0 )); | |||
err = PyErr_Occurred(); | err = PyErr_Occurred(); | |||
if(err) { | if(err) { | |||
PyErr_Print(); | PyErr_Print(); | |||
PRINTFB(G, FB_Python, FB_Errors) | PRINTFB(G, FB_Python, FB_Errors) | |||
" PFlush: Uncaught exception. PyMOL may have a bug.\n" ENDFB(G); | " PFlush: Uncaught exception. PyMOL may have a bug.\n" ENDFB(G); | |||
} | } | |||
PLockAPIWhileBlocked(G); | PLockAPIWhileBlocked(G); | |||
OrthoCommandSetBusy(G, false); | OrthoCommandSetBusy(G, false); | |||
/* make sure no commands left at this level */ | /* make sure no commands left at this level */ | |||
while(OrthoCommandWaiting(G)) | while(OrthoCommandWaiting(G)) | |||
PFlushFast(G); | PFlushFast(G); | |||
OrthoCommandNest(G, -1); | OrthoCommandNest(G, -1); | |||
} | } | |||
if (buffer) | ||||
VLAFreeP(buffer); | ||||
} | } | |||
PUnblock(G); | PUnblock(G); | |||
} | } | |||
return did_work; | return did_work; | |||
} | } | |||
int PFlushFast(PyMOLGlobals * G) | int PFlushFast(PyMOLGlobals * G) | |||
{ | { | |||
/* NOTE: ASSUMES we currently have blocked Python threads and an unlocked API */ | /* NOTE: ASSUMES we currently have blocked Python threads and an unlocked API */ | |||
PyObject *err; | PyObject *err; | |||
int did_work = false; | int did_work = false; | |||
char *buffer = 0; | auto ortho = G->Ortho; | |||
int size; | while(!OrthoCommandIsEmpty(*ortho)){ | |||
while((size = OrthoCommandOutSize(G))){ | auto buffer = OrthoCommandOut(*ortho); | |||
if (!buffer){ | ||||
buffer = VLACalloc(char, size); | ||||
} else { | ||||
VLACheck(buffer, char, size); | ||||
} | ||||
OrthoCommandSetBusy(G, true); | OrthoCommandSetBusy(G, true); | |||
OrthoCommandOut(G, buffer); | ||||
OrthoCommandNest(G, 1); | OrthoCommandNest(G, 1); | |||
did_work = true; | did_work = true; | |||
PRINTFD(G, FB_Threads) | PRINTFD(G, FB_Threads) | |||
" PFlushFast-DEBUG: executing '%s' as thread %ld\n", buffer, | " PFlushFast-DEBUG: executing '%s' as thread %ld\n", buffer.c_str(), | |||
PyThread_get_thread_ident() | PyThread_get_thread_ident() | |||
ENDFD; | ENDFD; | |||
if(PyErr_Occurred()) { | if(PyErr_Occurred()) { | |||
PyErr_Print(); | PyErr_Print(); | |||
PRINTFB(G, FB_Python, FB_Errors) | PRINTFB(G, FB_Python, FB_Errors) | |||
" PFlushFast: Uncaught exception. PyMOL may have a bug.\n" ENDFB(G); | " PFlushFast: Uncaught exception. PyMOL may have a bug.\n" ENDFB(G); | |||
} | } | |||
PXDecRef(PYOBJECT_CALLFUNCTION(G->P_inst->parse, "si", buffer, 0)); | PXDecRef(PYOBJECT_CALLFUNCTION(G->P_inst->parse, "si", buffer.c_str(), 0)); | |||
err = PyErr_Occurred(); | err = PyErr_Occurred(); | |||
if(err) { | if(err) { | |||
PyErr_Print(); | PyErr_Print(); | |||
PRINTFB(G, FB_Python, FB_Errors) | PRINTFB(G, FB_Python, FB_Errors) | |||
" PFlushFast: Uncaught exception. PyMOL may have a bug.\n" ENDFB(G); | " PFlushFast: Uncaught exception. PyMOL may have a bug.\n" ENDFB(G); | |||
} | } | |||
OrthoCommandSetBusy(G, false); | OrthoCommandSetBusy(G, false); | |||
/* make sure no commands left at this level */ | /* make sure no commands left at this level */ | |||
while(OrthoCommandWaiting(G)) | while(OrthoCommandWaiting(G)) | |||
PFlushFast(G); | PFlushFast(G); | |||
OrthoCommandNest(G, -1); | OrthoCommandNest(G, -1); | |||
} | } | |||
if (buffer) | ||||
VLAFreeP(buffer); | ||||
return did_work; | return did_work; | |||
} | } | |||
void PBlockLegacy() | void PBlockLegacy() | |||
{ | { | |||
PBlock(SingletonPyMOLGlobals); | PBlock(SingletonPyMOLGlobals); | |||
} | } | |||
void PUnblockLegacy() | void PUnblockLegacy() | |||
{ | { | |||
End of changes. 21 change blocks. | ||||
53 lines changed or deleted | 29 lines changed or added |