HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VOP_Snippet.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  * NAME: VOP Library (C++)
7  *
8  */
9 
10 #ifndef __VOP_Snippet_h__
11 #define __VOP_Snippet_h__
12 
13 #include "VOP_API.h"
14 #include "VOP_Node.h"
15 
16 class VCC_Location;
17 
19 {
20 public:
21  static OP_Node *myConstructor(OP_Network *net,
22  const char *name,
23  OP_Operator *entry);
24  static PRM_Template *buildTemplates();
25 
26 
27  static UT_StringHolder buildOuterCode(
28  const char *returntype,
29  const char *funcname,
30  const char *boundprefix,
31  const char *snippet,
32  const char *inputlist,
33  const char *exportlist,
34  bool toplevel,
35  bool strict_varnames,
36  bool vexstrict,
37  bool linehints,
38  const char *linefile,
39  const VOP_Language *language,
40  const VOP_GlobalVarMap *globalvariables);
41 
42  // Adjusts the location to take into account any bound variables.
43  static void adjustLocation(const char *snippet, bool strict_varnames, VCC_Location &loc);
44 
45 
46  void getOuterCode(
47  UT_String &codestr,
48  const VOP_CodeGenContext &context) override;
49 
50  void getCode(UT_String &codestr,
51  const VOP_CodeGenContext &context
52  ) override;
53 
54  bool definesShaderExtraParameters() const override
55  { return true; }
58  UT_IntArray &doexport,
59  UT_StringArray &names,
60  UT_StringArray &def,
61  VOP_Type shader_type = VOP_TYPE_UNDEF )
62  const override;
63 
64  const char *inputLabel(unsigned idx) const override;
65  const char *outputLabel(unsigned idx) const override;
66 
67  unsigned getNumVisibleInputs() const override;
68  unsigned getNumVisibleOutputs() const override;
69 
71  const VOP_CodeGenContext &context,
72  bool check_shader_context
73  ) const override;
74 
75  void postOpChanged(
76  OP_EventType reason,
77  void *data) override;
78 
79  /// The following are used to rewire our inputs so things
80  /// remain kosher.
81  void moveInput(int srcidx, int dstidx,
82  bool forcesubnet = false) override;
83 
84  OP_ERROR setInput(unsigned idx, OP_Node *op,
85  unsigned outputidx = 0) override;
87  unsigned idx,
88  const char *label,
89  int keeppos,
90  unsigned outputidx = 0) override;
91 
93  const OP_ConnectorId &input_name,
94  OP_Node *op,
95  const OP_ConnectorId *output_name=NULL
96  ) override;
98  const OP_ConnectorId &input_name,
99  const char *label,
100  int,
101  const OP_ConnectorId *output_name=NULL
102  ) override;
103 
104 
105  VOP_Node * findSimpleInputFromOutput(int index) override;
107  int output_index,
108  UT_IntArray &input_indices) override;
109 
110 protected:
111  VOP_Snippet(OP_Network *parent, const char *name, OP_Operator *entry);
112  ~VOP_Snippet() override;
113 
114  void getDescriptiveParmName(UT_String &name) const override
115  { name = "code"; }
116 
117  void preOpChanged(OP_EventType reason, void *data) override;
118 
120  UT_String &in, int idx) const override;
122  const UT_String &in) const override;
124  VOP_TypeInfo &type_info, int idx) override;
125 
127  UT_String &out, int idx) const override;
129  VOP_TypeInfo &type_info, int idx) override;
130 
131  void adjustOutputParmsForInputChange(int idx,
132  bool inputnull);
133  void adjustOutputParmsForNamedInputChange(
134  const OP_ConnectorId& input_name,
135  bool inputnull);
136  void swapInputs(int srcidx, int dstidx);
137 
138  void addDiagnosticInfo(
139  const VCC_DiagnosticInfo &diag) override;
140 
141  int getShaderExtraParametersHelper(
143  UT_IntArray &doexport,
144  UT_StringArray &names,
145  UT_StringArray &raw_names,
146  UT_StringArray &def,
147  VOP_Type shader_type = VOP_TYPE_UNDEF )
148  const;
149 private:
150  void getBaseOutputName(UT_String &out, int idx) const;
151  int NUMPARMS() const;
152  bool VEX_STRICT() const;
153  bool FORCECODEGENERATION() const;
154  bool STRICTVARIABLES() const;
155  void OUTPUTNAME(UT_String &str, int idx, bool expand) const;
156  CH_StringMeaning OUTPUTNAMEmeaning(int idx) const;
157  void setOutputParm(UT_String &str, CH_StringMeaning meaning,
158  int idx);
159  void OUTPUTLABEL(UT_String &str, int idx) const;
160  void EXPORTLIST(UT_StringHolder &str) const;
161  void getFunctionName(UT_String &fname) const;
162 
163  void evaluateCode(UT_StringHolder &codestr) const;
164  void cppStripCode(UT_StringHolder &codestr) const;
165  static bool adjustColumnForBindings(const char *l, int &col, bool strict_varnames);
166 
167  bool mySearchingForInputs;
168 };
169 
170 #endif
virtual int getInputFromNameSubclass(const UT_String &in) const
Reprsents a language for which VOPs can generate source code.
Definition: VOP_Language.h:29
virtual void getOuterCode(UT_String &codestr, const VOP_CodeGenContext &context)
virtual void addDiagnosticInfo(const VCC_DiagnosticInfo &diag)
void moveInput(int srcidx, int dstidx, bool forcesubnet=false) override
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
OP_ERROR setNamedInputReference(const OP_ConnectorId &input_name, const char *label, int, const OP_ConnectorId *output_name=nullptr) override
bool definesShaderExtraParameters() const override
Definition: VOP_Snippet.h:54
CH_StringMeaning
virtual bool forceCodeGenerationOfInputs(const VOP_CodeGenContext &context, bool check_shader_context) const
virtual unsigned getNumVisibleInputs() const
virtual int getShaderExtraParameters(UT_Array< VOP_Type > &types, UT_IntArray &doexport, UT_StringArray &names, UT_StringArray &def, VOP_Type shader_type=VOP_TYPE_UNDEF) const
virtual const char * inputLabel(unsigned idx) const
OP_ERROR setInput(unsigned idx, OP_Node *op, unsigned outputIdx=0) override
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual unsigned getNumVisibleOutputs() const
OP_ERROR setInputReference(unsigned idx, const char *label, int keeppos, unsigned outputIdx=0) override
Connects an input to particular node by name in the network.
virtual void getInputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
virtual void findSimpleInputCandidatesFromOutput(int output_index, UT_IntArray &input_indices)
Definition: VOP_Node.h:1269
#define VOP_API
Definition: VOP_API.h:10
virtual void preOpChanged(OP_EventType, void *)
Definition: VOP_Node.h:1453
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual VOP_Node * findSimpleInputFromOutput(int output_index)
Definition: VOP_Node.h:1264
virtual void getCode(UT_String &codestr, const VOP_CodeGenContext &context)
Get the code fragment to be included in the shader code.
virtual const char * outputLabel(unsigned idx) const
virtual void getOutputTypeInfoSubclass(VOP_TypeInfo &type_info, int idx)
virtual void getOutputNameSubclass(UT_String &out, int idx) const
GLuint index
Definition: glcorearb.h:786
OP_EventType
Definition: OP_Value.h:22
void getDescriptiveParmName(UT_String &name) const override
Definition: VOP_Snippet.h:114
VOP_Type
Enumeration of the built-in (basic) VOP data types.
Definition: VOP_Types.h:25
virtual void getInputNameSubclass(UT_String &in, int idx) const
GLsizei GLenum GLenum * types
Definition: glcorearb.h:2542
Definition: format.h:895
OP_ERROR setNamedInput(const OP_ConnectorId &input_name, OP_Node *op, const OP_ConnectorId *output_name=nullptr) override
New input functions that use names instead of indices.
virtual void postOpChanged(OP_EventType, void *)
Definition: VOP_Node.h:1455