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:
26
Test/baseResults/preprocessor.cpp_style___FILE__.vert.out
Normal file
26
Test/baseResults/preprocessor.cpp_style___FILE__.vert.out
Normal file
@@ -0,0 +1,26 @@
|
||||
#extension GL_GOOGLE_cpp_style_line_directive : enable
|
||||
|
||||
0
|
||||
#line 150 a.h
|
||||
"a.h"
|
||||
#line 24
|
||||
"a.h"
|
||||
#line 42
|
||||
"a.h"
|
||||
#line 30 b.cc
|
||||
"b.cc"
|
||||
#line 10 3
|
||||
3
|
||||
#line 48
|
||||
3
|
||||
#line 4
|
||||
3
|
||||
#line 55 100
|
||||
100
|
||||
#line 1000 c
|
||||
"c"
|
||||
#line 42 1
|
||||
1
|
||||
#line 42 this-is-a-quite-long-name-maybe-i-should-shorten-it
|
||||
"this-is-a-quite-long-name-maybe-i-should-shorten-it"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
ERROR: 0:3: '#error' : at 0:3
|
||||
ERROR: a.h:150: '#error' : at a.h:150
|
||||
ERROR: a.h:24: '#error' : at a.h:24
|
||||
ERROR: a.h:42: '#error' : at a.h:42
|
||||
ERROR: b.cc:30: '#error' : at b.cc:30
|
||||
ERROR: 3:10: '#error' : at 3:10
|
||||
ERROR: 3:48: '#error' : at 3:48
|
||||
ERROR: 3:4: '#error' : at 3:4
|
||||
ERROR: 100:55: '#error' : at 100:55
|
||||
ERROR: c:1000: '#error' : at c:1000
|
||||
ERROR: 1:42: '#error' : at 1:42
|
||||
ERROR: this-is-a-quite-long-name-maybe-i-should-shorten-it:42: '#error' : at this-is-a-quite-long-name-maybe-i-should-shorten-it:42
|
||||
ERROR: 12 compilation errors. No code generated.
|
||||
|
||||
|
||||
36
Test/preprocessor.cpp_style___FILE__.vert
Normal file
36
Test/preprocessor.cpp_style___FILE__.vert
Normal file
@@ -0,0 +1,36 @@
|
||||
#extension GL_GOOGLE_cpp_style_line_directive : enable
|
||||
|
||||
__FILE__
|
||||
|
||||
#line 150 "a.h"
|
||||
__FILE__
|
||||
|
||||
#line 24
|
||||
__FILE__
|
||||
|
||||
#line 42
|
||||
__FILE__
|
||||
|
||||
#line 30 "b.cc"
|
||||
__FILE__
|
||||
|
||||
#line 10 3
|
||||
__FILE__
|
||||
|
||||
#line 48
|
||||
__FILE__
|
||||
|
||||
#line 4
|
||||
__FILE__
|
||||
|
||||
#line 55 100
|
||||
__FILE__
|
||||
|
||||
#line 1000 "c"
|
||||
__FILE__
|
||||
|
||||
#line 42 1
|
||||
__FILE__
|
||||
|
||||
#line 42 "this-is-a-quite-long-name-maybe-i-should-shorten-it"
|
||||
__FILE__
|
||||
36
Test/preprocessor.cpp_style_line_directive.vert
Normal file
36
Test/preprocessor.cpp_style_line_directive.vert
Normal file
@@ -0,0 +1,36 @@
|
||||
#extension GL_GOOGLE_cpp_style_line_directive : enable
|
||||
|
||||
#error at "0:3"
|
||||
|
||||
#line 150 "a.h"
|
||||
#error at "a.h:150"
|
||||
|
||||
#line 24
|
||||
#error at "a.h:24"
|
||||
|
||||
#line 42
|
||||
#error at "a.h:42"
|
||||
|
||||
#line 30 "b.cc"
|
||||
#error at "b.cc:30"
|
||||
|
||||
#line 10 3
|
||||
#error at "3:10"
|
||||
|
||||
#line 48
|
||||
#error at "3:48"
|
||||
|
||||
#line 4
|
||||
#error at "3:4"
|
||||
|
||||
#line 55 100
|
||||
#error at "100:55"
|
||||
|
||||
#line 1000 "c"
|
||||
#error at "c:1000"
|
||||
|
||||
#line 42 1
|
||||
#error at "1:42"
|
||||
|
||||
#line 42 "this-is-a-quite-long-name-maybe-i-should-shorten-it"
|
||||
#error at "this-is-a-quite-long-name-maybe-i-should-shorten-it:42"
|
||||
@@ -1,3 +1,4 @@
|
||||
preprocessor.cpp_style_line_directive.vert
|
||||
preprocessor.edge_cases.vert
|
||||
preprocessor.errors.vert
|
||||
preprocessor.extensions.vert
|
||||
|
||||
Reference in New Issue
Block a user