|
|
@@ -3435,81 +3435,6 @@ make_compute(ShaderLanguage lang, string body) {
|
|
|
return shader;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Set a 'parse pointer' to the beginning of the shader.
|
|
|
- */
|
|
|
-void Shader::
|
|
|
-parse_init() {
|
|
|
- _parse = 0;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Parse a line of text. If 'lt' is true, trim blanks from the left end of
|
|
|
- * the line. If 'rt' is true, trim blanks from the right end (the newline is
|
|
|
- * always trimmed).
|
|
|
- */
|
|
|
-void Shader::
|
|
|
-parse_line(string &result, bool lt, bool rt) {
|
|
|
- nassertv(!_text._separate);
|
|
|
- int len = _text._shared.size();
|
|
|
- int head = _parse;
|
|
|
- int tail = head;
|
|
|
- while ((tail < len) && (_text._shared[tail] != '\n')) {
|
|
|
- tail++;
|
|
|
- }
|
|
|
- if (tail < len) {
|
|
|
- _parse = tail+1;
|
|
|
- } else {
|
|
|
- _parse = tail;
|
|
|
- }
|
|
|
- if (lt) {
|
|
|
- while ((head < tail)&&(isspace(_text._shared[head]))) head++;
|
|
|
- while ((tail > head)&&(isspace(_text._shared[tail-1]))) tail--;
|
|
|
- }
|
|
|
- result = _text._shared.substr(head, tail-head);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Parse lines until you read a line that matches the specified pattern.
|
|
|
- * Returns all the preceding lines, and if the include flag is set, returns
|
|
|
- * the final line as well.
|
|
|
- */
|
|
|
-void Shader::
|
|
|
-parse_upto(string &result, string pattern, bool include) {
|
|
|
- nassertv(!_text._separate);
|
|
|
- GlobPattern endpat(pattern);
|
|
|
- int start = _parse;
|
|
|
- int last = _parse;
|
|
|
- while (_parse < (int)(_text._shared.size())) {
|
|
|
- string t;
|
|
|
- parse_line(t, true, true);
|
|
|
- if (endpat.matches(t)) break;
|
|
|
- last = _parse;
|
|
|
- }
|
|
|
- if (include) {
|
|
|
- result = _text._shared.substr(start, _parse - start);
|
|
|
- } else {
|
|
|
- result = _text._shared.substr(start, last - start);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Returns the rest of the text from the current parse location.
|
|
|
- */
|
|
|
-void Shader::
|
|
|
-parse_rest(string &result) {
|
|
|
- nassertv(!_text._separate);
|
|
|
- result = _text._shared.substr(_parse, _text._shared.size() - _parse);
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Returns true if the parse pointer is at the end of the shader.
|
|
|
- */
|
|
|
-bool Shader::
|
|
|
-parse_eof() {
|
|
|
- return (int)_text._shared.size() == _parse;
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* Indicates that the shader should be enqueued to be prepared in the
|
|
|
* indicated prepared_objects at the beginning of the next frame. This will
|