Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/PreprocessorWrapper.h
Show All 15 Lines | ||||||||||
*/ | */ | |||||||||
#ifndef INCLUDED_PREPROCESSORWRAPPER | #ifndef INCLUDED_PREPROCESSORWRAPPER | |||||||||
#define INCLUDED_PREPROCESSORWRAPPER | #define INCLUDED_PREPROCESSORWRAPPER | |||||||||
#include "ps/CStr.h" | #include "ps/CStr.h" | |||||||||
#include "third_party/ogre3d_preprocessor/OgreGLSLPreprocessor.h" | #include "third_party/ogre3d_preprocessor/OgreGLSLPreprocessor.h" | |||||||||
#include <functional> | ||||||||||
#include <map> | ||||||||||
StanUnsubmitted Not Done Inline Actions
Stan: | ||||||||||
class CShaderDefines; | class CShaderDefines; | |||||||||
/** | /** | |||||||||
* Convenience wrapper around CPreprocessor. | * Convenience wrapper around CPreprocessor. | |||||||||
*/ | */ | |||||||||
class CPreprocessorWrapper | class CPreprocessorWrapper | |||||||||
{ | { | |||||||||
public: | public: | |||||||||
using IncludeRetrieverCallback = std::function<bool(const CStr&, CStr& out)>; | ||||||||||
CPreprocessorWrapper(); | CPreprocessorWrapper(); | |||||||||
CPreprocessorWrapper(const IncludeRetrieverCallback& includeCallback); | ||||||||||
void AddDefine(const char* name, const char* value); | void AddDefine(const char* name, const char* value); | |||||||||
void AddDefines(const CShaderDefines& defines); | void AddDefines(const CShaderDefines& defines); | |||||||||
bool TestConditional(const CStr& expr); | bool TestConditional(const CStr& expr); | |||||||||
// Find all #include directives in the input and replace them by | ||||||||||
// by a file content from the directive's argument. Parsing is strict | ||||||||||
// and simple. The directive will be expanded in comments and multiline | ||||||||||
// strings. | ||||||||||
CStr ResolveIncludes(CStr source); | ||||||||||
CStr Preprocess(const CStr& input); | CStr Preprocess(const CStr& input); | |||||||||
static void PyrogenesisShaderError(int iLine, const char* iError, const Ogre::CPreprocessor::Token* iToken); | static void PyrogenesisShaderError(int iLine, const char* iError, const Ogre::CPreprocessor::Token* iToken); | |||||||||
private: | private: | |||||||||
Ogre::CPreprocessor m_Preprocessor; | Ogre::CPreprocessor m_Preprocessor; | |||||||||
IncludeRetrieverCallback m_IncludeCallback; | ||||||||||
std::map<CStr, CStr> m_IncludeCache; | ||||||||||
StanUnsubmitted Done Inline ActionsDo you need ordering? Stan: Do you need ordering? | ||||||||||
vladislavbelovAuthorUnsubmitted Done Inline ActionsNo, but afaik we don't have std::hash for CStr, so I'm planning to add that in a separate patch. vladislavbelov: No, but afaik we don't have `std::hash` for `CStr`, so I'm planning to add that in a separate… | ||||||||||
wraitiiUnsubmitted Not Done Inline Actionsyou ought to be able to use std::string somewhat transparently, but your call. wraitii: you ought to be able to use std::string somewhat transparently, but your call. | ||||||||||
StanUnsubmitted Done Inline ActionsYou have it now :) Stan: You have it now :) | ||||||||||
}; | }; | |||||||||
#endif // INCLUDED_PREPROCESSORWRAPPER | #endif // INCLUDED_PREPROCESSORWRAPPER |
Wildfire Games · Phabricator