HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PY_Result.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  * This class holds the result of python code that was run.
8  */
9 
10 #ifndef __PY_Result_h__
11 #define __PY_Result_h__
12 
13 #include "PY_API.h"
14 #include "PY_OpaqueObject.h"
15 #include <UT/UT_StringArray.h>
16 #include <UT/UT_StringHolder.h>
17 #include <UT/UT_Options.h>
18 #include <UT/UT_Variant.h>
19 #include <vector>
20 
21 // This class contains information about the return value of python code
22 // that was executed.
24 {
25 public:
27  : myResultType(NONE)
28  , myOpaquePyObject(nullptr)
29  , myVoidPtr(nullptr)
30  {}
31 
32  UT_StringHolder asStringForDebugging();
33 
35 
36  // Errors (uncaught exceptions) and exit requests (because sys.exit()
37  // was called) are possible result types, in addition to the standard
38  // int, double, and string types. (Python uses doubles internally,
39  // so double is used instead of float.) If the python None object is
40  // returned or some other object is returned, the result type is "none".
41  // If you request a result type of PY_OBJECT, the raw PyObject * is
42  // set and it is up to you to decrement the reference count on it.
43  enum Type { INT, DOUBLE, STRING, INT_ARRAY, DOUBLE_ARRAY, STRING_ARRAY,
44  OPTIONS, PY_OBJECT, VOID_PTR, NONE, EXIT, ERR, VARIANT };
46 
47  // Type Fields Used
48  // ------- -----------
49  // INT myIntValue
50  // DOUBLE myDoubleValue
51  // STRING myStringValue
52  // INT_ARRAY myIntArray
53  // DOUBLE_ARRAY myDoubleArray
54  // STRING_ARRAY myStringArray
55  // OPTIONS myOptions
56  // PY_OBJECT myOpaquePyObject
57  // VOID_PTR myVoidPtr
58  // VARIANT myValue - Always filled in.
59  // NONE none
60  // EXIT myIntValue for exit code, myStringValue in case
61  // user called sys.exit() with a non-integer object
62  // ERR myDetailedErrValue for exception back trace
63  // myErrValue for a simplified error message
64  // myExceptionClass is the name of the exception (if any)
65 
67  double myDoubleValue;
69  std::vector<int> myIntArray;
70  std::vector<double> myDoubleArray;
77  void *myVoidPtr;
78 };
79 
80 #endif
UT_Variant myValue
Definition: PY_Result.h:34
UT_Options myOptions
Definition: PY_Result.h:72
UT_StringHolder myStringValue
Definition: PY_Result.h:68
PY_OpaqueObject myOpaquePyObject
Definition: PY_Result.h:76
std::vector< int > myIntArray
Definition: PY_Result.h:69
std::vector< double > myDoubleArray
Definition: PY_Result.h:70
#define PY_API
Definition: PY_API.h:10
void * myVoidPtr
Definition: PY_Result.h:77
MX_GENSHADER_API const TypeDesc * STRING
A map of string to various well defined value types.
Definition: UT_Options.h:84
UT_StringHolder myErrValue
Definition: PY_Result.h:73
UT_StringHolder myExceptionClass
Definition: PY_Result.h:75
UT_StringHolder myDetailedErrValue
Definition: PY_Result.h:74
PY_Result()
Definition: PY_Result.h:26
UT_StringArray myStringArray
Definition: PY_Result.h:71
Type myResultType
Definition: PY_Result.h:45
double myDoubleValue
Definition: PY_Result.h:67
int myIntValue
Definition: PY_Result.h:66