VR-Forces Developer's Guide
 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:
84  static std::string preprocess(const std::string& inputSource);
85  protected:
88 
90  virtual ~DtGLSLPreprocessor();
91 
92  private:
94  DtGLSLPreprocessor(const DtGLSLPreprocessor& rhs) = delete;
96  DtGLSLPreprocessor& operator=(const DtGLSLPreprocessor& rhs) = delete;
97  protected:
109  void Define(const char *iMacroName, size_t iMacroNameLen,
110  const char *iMacroValue, size_t iMacroValueLen);
111 
121  void Define(const char *iMacroName, size_t iMacroNameLen, long iMacroValue);
122 
132  bool Undef(const char *iMacroName, size_t iMacroNameLen);
133 
156  std::string Parse(const std::string& inputSource);
157 
173  typedef void(*ErrorHandlerFunc) (
174  void *iData, int iLine, const char *iError,
175  const char *iToken, size_t iTokenLen);
176 
182  static ErrorHandlerFunc ErrorHandler;
183 
185  void *ErrorData;
186 
190  DtGLSLPreprocessor(const DtGLSLToken &iToken, int iLine);
191 
199  DtGLSLToken GetToken(bool iExpand);
200 
210  DtGLSLToken HandleDirective(DtGLSLToken &iToken, int iLine);
211 
222  bool HandleDefine(DtGLSLToken &iBody, int iLine);
223 
234  bool HandleUnDef(DtGLSLToken &iBody, int iLine);
235 
246  bool HandleIfDef(DtGLSLToken &iBody, int iLine);
247 
258  bool HandleIf(DtGLSLToken &iBody, int iLine);
259 
270  bool HandleElif(DtGLSLToken &iBody, int iLine);
271 
282  bool HandleElse(DtGLSLToken &iBody, int iLine);
283 
294  bool HandleEndIf(DtGLSLToken &iBody, int iLine);
295 
311  DtGLSLToken GetArgument(DtGLSLToken &oArg, bool iExpand, bool shouldAppendArg);
312 
325  DtGLSLToken GetArguments(int &oNumArgs, DtGLSLToken *&oArgs, bool iExpand, bool shouldAppendArg);
326 
340  DtGLSLToken GetExpression(DtGLSLToken &oResult, int iLine, int iOpPriority = 0);
341 
357  bool GetValue(const DtGLSLToken &iToken, long &oValue, int iLine);
358 
367  DtGLSLToken ExpandMacro(const DtGLSLToken &iToken);
368 
376  DtGLSLMacro *IsDefined(const DtGLSLToken &iToken);
377 
389  static DtGLSLToken ExpandDefined(DtGLSLPreprocessor *iParent, int iNumArgs, DtGLSLToken *iArgs);
390 
398  DtGLSLToken Parse(const DtGLSLToken &iSource);
399 
409  void Error(int iLine, const char *iError, const DtGLSLToken *iToken = NULL);
410 
411  friend class DtGLSLMacro;
412 
414  const char *Source;
416  const char *SourceEnd;
418  int Line;
420  bool BOL;
422  unsigned EnableOutput;
425  };
426 
427 } // namespace makVrv
428 
const char * Source
The current source text input.
Definition: DtGLSLPreprocessor.h:414
#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:420
const char * SourceEnd
The end of the source text.
Definition: DtGLSLPreprocessor.h:416
glsl macro
unsigned EnableOutput
A stack of 32 booleans packed into one value :)
Definition: DtGLSLPreprocessor.h:422
A input token.
Definition: DtGLSLToken.h:29
static ErrorHandlerFunc ErrorHandler
A pointer to the preprocessor&#39;s error handler.
Definition: DtGLSLPreprocessor.h:182
void * ErrorData
User-specific storage, passed to Error()
Definition: DtGLSLPreprocessor.h:185
DtGLSLMacro * MacroList
The list of macros defined so far.
Definition: DtGLSLPreprocessor.h:424
int Line
Current line number.
Definition: DtGLSLPreprocessor.h:418
A macro definition.
Definition: DtGLSLMacro.h:22
Contains DLL export macros.

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)