00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 123 Front Street West, Suite 1401 00009 * Toronto, Ontario 00010 * Canada M5J 2M2 00011 * 416-504-9876 00012 * 00013 * COMMENTS: 00014 * This class holds the result of python code that was run. 00015 */ 00016 00017 #ifndef __PY_Result_h__ 00018 #define __PY_Result_h__ 00019 00020 #include "PY_API.h" 00021 #include <UT/UT_StringArray.h> 00022 #include <UT/UT_Options.h> 00023 00024 // This class contains information about the return value of python code 00025 // that was executed. 00026 class PY_API PY_Result 00027 { 00028 public: 00029 PY_Result() 00030 : myResultType(NONE) 00031 , myStringValue(UT_String::ALWAYS_DEEP) 00032 , myErrValue(UT_String::ALWAYS_DEEP) 00033 , myDetailedErrValue(UT_String::ALWAYS_DEEP) 00034 , myExceptionClass(UT_String::ALWAYS_DEEP) 00035 {} 00036 00037 UT_String asStringForDebugging(); 00038 00039 // Errors (uncaught exceptions) and exit requests (because sys.exit() 00040 // was called) are possible result types, in addition to the standard 00041 // int, double, and string types. (Python uses doubles internally, 00042 // so double is used instead of float.) If the python None object is 00043 // returned or some other object is returned, the result type is "none". 00044 // If you request a result type of PY_OBJECT, the raw PyObject * is 00045 // set and it is up to you to decrement the reference count on it. 00046 enum Type { INT, DOUBLE, STRING, INT_ARRAY, DOUBLE_ARRAY, STRING_ARRAY, 00047 OPTIONS, PY_OBJECT, NONE, EXIT, ERR }; 00048 Type myResultType; 00049 00050 // Type Fields Used 00051 // ------- ----------- 00052 // INT myIntValue 00053 // DOUBLE myDoubleValue 00054 // STRING myStringValue 00055 // INT_ARRAY myIntArray 00056 // DOUBLE_ARRAY myDoubleArray 00057 // STRING_ARRAY myStringArray 00058 // OPTIONS myOptions 00059 // PY_OBJECT myOpaquePyObject 00060 // NONE none 00061 // EXIT myIntValue for exit code, myStringValue in case 00062 // user called sys.exit() with a non-integer object 00063 // ERR myDetailedErrValue for exception back trace 00064 // myErrValue for a simplified error message 00065 // myExceptionClass is the name of the exception (if any) 00066 00067 int myIntValue; 00068 double myDoubleValue; 00069 UT_String myStringValue; 00070 std::vector<int> myIntArray; 00071 std::vector<double> myDoubleArray; 00072 UT_StringArray myStringArray; 00073 UT_Options myOptions; 00074 UT_String myErrValue; 00075 UT_String myDetailedErrValue; 00076 UT_String myExceptionClass; 00077 void *myOpaquePyObject; 00078 }; 00079 00080 #endif
1.5.9