Mesa (mesa_7_5_branch): glsl: Expand nested preprocessor macros.
Brian Paul
brianp at kemper.freedesktop.org
Tue Jun 9 15:14:55 UTC 2009
Module: Mesa
Branch: mesa_7_5_branch
Commit: cb549775a577cc5c86fefdc7e208b9d5e1d25217
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb549775a577cc5c86fefdc7e208b9d5e1d25217
Author: Brian Paul <brianp at vmware.com>
Date: Tue Jun 9 09:14:38 2009 -0600
glsl: Expand nested preprocessor macros.
(cherry picked from master, commit ef8caec29ae73bb2bbeb48f0578d839ef29348cd)
---
src/mesa/shader/slang/slang_preprocess.c | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c
index fd98fae..0e95cdb 100644
--- a/src/mesa/shader/slang/slang_preprocess.c
+++ b/src/mesa/shader/slang/slang_preprocess.c
@@ -1012,6 +1012,8 @@ preprocess_source (slang_string *output, const char *source,
case TOKEN_DEFINE:
{
pp_symbol *symbol = NULL;
+ slang_string replacement;
+ expand_state es;
/* Parse macro name. */
id = (const char *) (&prod[i]);
@@ -1054,9 +1056,20 @@ preprocess_source (slang_string *output, const char *source,
idlen = _mesa_strlen (id);
if (state.cond.top->effective) {
pp_annotate (output, ") %s", id);
- slang_string_pushs (&symbol->replacement, id, idlen);
}
+ slang_string_init(&replacement);
+ slang_string_pushs(&replacement, id, idlen);
i += idlen + 1;
+
+ /* Expand macro replacement. */
+ es.output = &symbol->replacement;
+ es.input = slang_string_cstr(&replacement);
+ es.state = &state;
+ if (!expand(&es, &state.symbols)) {
+ slang_string_free(&replacement);
+ goto error;
+ }
+ slang_string_free(&replacement);
}
break;
More information about the mesa-commit
mailing list