[Hdrflow-svn] SF.net SVN: hdrflow: [214] trunk/app/HDRFlow
Status: Pre-Alpha
Brought to you by:
glslang
From: <gl...@us...> - 2007-07-28 18:46:41
|
Revision: 214 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=214&view=rev Author: glslang Date: 2007-07-28 11:46:38 -0700 (Sat, 28 Jul 2007) Log Message: ----------- +script editor improvements Modified Paths: -------------- trunk/app/HDRFlow/English.lproj/Preferences.nib/info.nib trunk/app/HDRFlow/English.lproj/Preferences.nib/keyedobjects.nib trunk/app/HDRFlow/ScriptEngine.cpp trunk/app/HDRFlow/ViewportOpenGLView.m Modified: trunk/app/HDRFlow/English.lproj/Preferences.nib/info.nib =================================================================== --- trunk/app/HDRFlow/English.lproj/Preferences.nib/info.nib 2007-07-28 17:32:52 UTC (rev 213) +++ trunk/app/HDRFlow/English.lproj/Preferences.nib/info.nib 2007-07-28 18:46:38 UTC (rev 214) @@ -9,7 +9,7 @@ <key>10</key> <string>514 465 412 270 0 0 1440 878 </string> <key>12</key> - <string>395 379 650 442 0 0 1440 878 </string> + <string>500 476 439 314 0 0 1440 878 </string> <key>33</key> <string>519 453 401 293 0 0 1440 878 </string> </dict> @@ -17,10 +17,10 @@ <string>446.1</string> <key>IBOpenObjects</key> <array> - <integer>12</integer> + <integer>33</integer> <integer>5</integer> - <integer>33</integer> <integer>10</integer> + <integer>12</integer> </array> <key>IBSystem Version</key> <string>8R2218</string> Modified: trunk/app/HDRFlow/English.lproj/Preferences.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/app/HDRFlow/ScriptEngine.cpp =================================================================== --- trunk/app/HDRFlow/ScriptEngine.cpp 2007-07-28 17:32:52 UTC (rev 213) +++ trunk/app/HDRFlow/ScriptEngine.cpp 2007-07-28 18:46:38 UTC (rev 214) @@ -23,11 +23,57 @@ py::object strobj( py::handle<>( PyObject_Str( obj ) ) ); py::extract<std::string> extract( strobj ); if( extract.check( ) ) - return extract( ); + return extract( ) + "\n"; } return pl::string( ); } + + std::pair<pl::string, bool> in_python( const pl::string& script, int start ) + { + pl::string result; + + py::object main_module( py::handle<>( py::borrowed( PyImport_AddModule( "__main__" ) ) ) ); + py::object main_namespace = main_module.attr( "__dict__" ); + + PyErr_Clear( ); + + try + { + pl::string eval_result; + + py::handle<> handle( PyRun_String( script.c_str( ), start, main_namespace.ptr( ), main_namespace.ptr( ) ) ); + + py::object strobj( py::handle<>( PyObject_Str( py::object( handle ).ptr( ) ) ) ); + if( strobj ) + { + eval_result = PyString_AsString( strobj.ptr( ) ); + if( eval_result != "None" ) + result += eval_result + "\n"; + } + } + catch( py::error_already_set ) + { + PyObject* error_type; + PyObject* error_data; + PyObject* error_traceback; + + PyErr_Fetch( &error_type, &error_data, &error_traceback ); + PyErr_NormalizeException( &error_type, &error_data, &error_traceback ); + + result += error_to_result( error_type ); + result += error_to_result( error_data ); + result += error_to_result( error_traceback ); + + Py_XDECREF( error_type ); + Py_XDECREF( error_data ); + Py_XDECREF( error_traceback ); + + return std::pair<pl::string, bool>( result, false ); + } + + return std::pair<pl::string, bool>( result, true ); + } } ScriptEngine::ScriptEngine( ) @@ -42,11 +88,8 @@ bool ScriptEngine::eval( const pl::string& str ) { - py::object main_module( py::handle<>( py::borrowed( PyImport_AddModule( "__main__" ) ) ) ); - py::object main_namespace = main_module.attr( "__dict__" ); + result_.clear( ); - result_.clear( ); - std::string trim_str( str.c_str( ) ); boost::trim( trim_str ); @@ -58,47 +101,12 @@ for( const_iterator I = split_vec.begin( ); I != split_vec.end( ); ++I ) result_ += "# " + *I + "\n"; - int start = split_vec.size( ) == 1 && - split_vec[ 0 ].find( "import" ) == std::string::npos && split_vec[ 0 ].find( "def" ) == std::string::npos ? Py_eval_input : Py_file_input; + std::pair<pl::string, bool> result = in_python( str, Py_eval_input ); + if( !result.second ) + result = in_python( str, Py_file_input ); - try - { - pl::string eval_result; - - py::handle<> handle( PyRun_String( str.c_str( ), start, main_namespace.ptr( ), main_namespace.ptr( ) ) ); - - py::object strobj( py::handle<>( PyObject_Str( py::object( handle ).ptr( ) ) ) ); - if( strobj ) - { - eval_result = PyString_AsString( strobj.ptr( ) ); - if( eval_result != "None" ) - result_ += eval_result + "\n"; - } - } - catch( py::error_already_set ) - { - PyObject* error_type; - PyObject* error_data; - PyObject* error_traceback; - - PyErr_Fetch( &error_type, &error_data, &error_traceback ); - PyErr_NormalizeException( &error_type, &error_data, &error_traceback ); - - result_ += error_to_result( error_type ); - result_ += error_to_result( error_data ); - result_ += error_to_result( error_traceback ); - - if( result_.empty( ) ) - result_ = "<no info available>"; - - Py_XDECREF( error_type ); - Py_XDECREF( error_data ); - Py_XDECREF( error_traceback ); - - return false; - } - - return true; + result_ += result.first; + return result.second; } pl::string ScriptEngine::result( ) const Modified: trunk/app/HDRFlow/ViewportOpenGLView.m =================================================================== --- trunk/app/HDRFlow/ViewportOpenGLView.m 2007-07-28 17:32:52 UTC (rev 213) +++ trunk/app/HDRFlow/ViewportOpenGLView.m 2007-07-28 18:46:38 UTC (rev 214) @@ -61,10 +61,7 @@ glViewport( 0, 0, NSWidth( bounds ), NSHeight( bounds ) ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); - if( [ self inLiveResize ] ) - glFlush( ); - else - [ [ self openGLContext ] flushBuffer ]; + [ [ self openGLContext ] flushBuffer ]; } - ( void ) prepareOpenGL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |