Extend the syntax of #line and __FILE__ to support filename strings.
According to the GLSL spec, the second parameter to #line should be an integer source string number and __FILE__ will be substituted with the integer source string number currently processed. This patch extends the syntax of #line and __FILE__. Now #line accepts as the second parameter a filename string quoted by double quotation marks. And if such a #line is set, __FILE__ will be substituted with the currently set filename string. The implementation is done via introducing a new extension GL_GOOGLE_cpp_style_line_directive using the extension framework. The purpose is to support cpp-style #line directives, which is required by #include.
This commit is contained in:
parent
c777fc2c4c
commit
5011fbebc3
16 changed files with 176 additions and 19 deletions
|
|
@ -214,6 +214,7 @@ public:
|
|||
int getNumErrors() const { return numErrors; }
|
||||
const TSourceLoc& getCurrentLoc() const { return currentScanner->getSourceLoc(); }
|
||||
void setCurrentLine(int line) { currentScanner->setLine(line); }
|
||||
void setCurrentSourceName(const char* name) { currentScanner->setFile(name); }
|
||||
void setCurrentString(int string) { currentScanner->setString(string); }
|
||||
void setScanner(TInputScanner* scanner) { currentScanner = scanner; }
|
||||
|
||||
|
|
@ -221,7 +222,7 @@ public:
|
|||
|
||||
void notifyVersion(int line, int version, const char* type_string);
|
||||
void notifyErrorDirective(int line, const char* error_message);
|
||||
void notifyLineDirective(int curLineNo, int newLineNo, bool hasSource, int sourceNum);
|
||||
void notifyLineDirective(int curLineNo, int newLineNo, bool hasSource, int sourceNum, const char* sourceName);
|
||||
void notifyExtensionDirective(int line, const char* extension, const char* behavior);
|
||||
|
||||
// The following are implemented in Versions.cpp to localize version/profile/stage/extensions control
|
||||
|
|
@ -243,7 +244,7 @@ public:
|
|||
|
||||
void setVersionCallback(const std::function<void(int, int, const char*)>& func) { versionCallback = func; }
|
||||
void setPragmaCallback(const std::function<void(int, const TVector<TString>&)>& func) { pragmaCallback = func; }
|
||||
void setLineCallback(const std::function<void(int, int, bool, int)>& func) { lineCallback = func; }
|
||||
void setLineCallback(const std::function<void(int, int, bool, int, const char*)>& func) { lineCallback = func; }
|
||||
void setExtensionCallback(const std::function<void(int, const char*, const char*)>& func) { extensionCallback = func; }
|
||||
void setErrorCallback(const std::function<void(int, const char*)>& func) { errorCallback = func; }
|
||||
|
||||
|
|
@ -357,7 +358,7 @@ protected:
|
|||
|
||||
// These, if set, will be called when a line, pragma ... is preprocessed.
|
||||
// They will be called with any parameters to the original directive.
|
||||
std::function<void(int, int, bool, int)> lineCallback;
|
||||
std::function<void(int, int, bool, int, const char*)> lineCallback;
|
||||
std::function<void(int, const TVector<TString>&)> pragmaCallback;
|
||||
std::function<void(int, int, const char*)> versionCallback;
|
||||
std::function<void(int, const char*, const char*)> extensionCallback;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue