VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtGLSLPreprocessor.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
38 #pragma once
39 
40 #include <vrvOsg/vrvOsg.h>
41 
42 #include <string.h>
43 #include <stdlib.h>
44 
45 #include <string>
46 
47 #include <vrvOsg/DtGLSLToken.h>
48 #include <vrvOsg/DtGLSLMacro.h>
49 
50 namespace makVrv
51 {
75  {
76  public:
79 
81  virtual ~DtGLSLPreprocessor();
82 
84  static std::string preprocess(const std::string& inputSource);
85 
86  protected:
98  void Define(const char *iMacroName, size_t iMacroNameLen,
99  const char *iMacroValue, size_t iMacroValueLen);
100 
110  void Define(const char *iMacroName, size_t iMacroNameLen, long iMacroValue);
111 
121  bool Undef(const char *iMacroName, size_t iMacroNameLen);
122 
145  std::string Parse(const std::string& inputSource);
146 
162  typedef void(*ErrorHandlerFunc) (
163  void *iData, int iLine, const char *iError,
164  const char *iToken, size_t iTokenLen);
165 
171  static ErrorHandlerFunc ErrorHandler;
172 
174  void *ErrorData;
175 
179  DtGLSLPreprocessor(const DtGLSLToken &iToken, int iLine);
180 
188  DtGLSLToken GetToken(bool iExpand);
189 
199  DtGLSLToken HandleDirective(DtGLSLToken &iToken, int iLine);
200 
211  bool HandleDefine(DtGLSLToken &iBody, int iLine);
212 
223  bool HandleUnDef(DtGLSLToken &iBody, int iLine);
224 
235  bool HandleIfDef(DtGLSLToken &iBody, int iLine);
236 
247  bool HandleIf(DtGLSLToken &iBody, int iLine);
248 
259  bool HandleElif(DtGLSLToken &iBody, int iLine);
260 
271  bool HandleElse(DtGLSLToken &iBody, int iLine);
272 
283  bool HandleEndIf(DtGLSLToken &iBody, int iLine);
284 
300  DtGLSLToken GetArgument(DtGLSLToken &oArg, bool iExpand, bool shouldAppendArg);
301 
314  DtGLSLToken GetArguments(int &oNumArgs, DtGLSLToken *&oArgs, bool iExpand, bool shouldAppendArg);
315 
329  DtGLSLToken GetExpression(DtGLSLToken &oResult, int iLine, int iOpPriority = 0);
330 
346  bool GetValue(const DtGLSLToken &iToken, long &oValue, int iLine);
347 
356  DtGLSLToken ExpandMacro(const DtGLSLToken &iToken);
357 
365  DtGLSLMacro *IsDefined(const DtGLSLToken &iToken);
366 
378  static DtGLSLToken ExpandDefined(DtGLSLPreprocessor *iParent, int iNumArgs, DtGLSLToken *iArgs);
379 
387  DtGLSLToken Parse(const DtGLSLToken &iSource);
388 
398  void Error(int iLine, const char *iError, const DtGLSLToken *iToken = NULL);
399 
400  friend class DtGLSLMacro;
401 
403  const char *Source;
405  const char *SourceEnd;
407  int Line;
409  bool BOL;
411  unsigned EnableOutput;
414  };
415 
416 } // namespace makVrv
417 
const char * Source
The current source text input.
Definition: DtGLSLPreprocessor.h:403
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
This is a simplistic C/C++-like preprocessor.
Definition: DtGLSLPreprocessor.h:74
glsl token
bool BOL
True if we are at beginning of line.
Definition: DtGLSLPreprocessor.h:409
const char * SourceEnd
The end of the source text.
Definition: DtGLSLPreprocessor.h:405
glsl macro
unsigned EnableOutput
A stack of 32 booleans packed into one value :)
Definition: DtGLSLPreprocessor.h:411
A input token.
Definition: DtGLSLToken.h:29
static ErrorHandlerFunc ErrorHandler
A pointer to the preprocessor&#39;s error handler.
Definition: DtGLSLPreprocessor.h:171
void * ErrorData
User-specific storage, passed to Error()
Definition: DtGLSLPreprocessor.h:174
DtGLSLMacro * MacroList
The list of macros defined so far.
Definition: DtGLSLPreprocessor.h:413
int Line
Current line number.
Definition: DtGLSLPreprocessor.h:407
A macro definition.
Definition: DtGLSLMacro.h:22
Contains DLL export macros.

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)