summaryrefslogtreecommitdiff
path: root/src/glsl/pp/sl_pp_extension.c
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2009-12-10 12:38:22 +0100
committerMichal Krol <michal@vmware.com>2009-12-10 12:38:22 +0100
commit91e164b3d0b1d36bfdf369266ae7e1ab396f1ba2 (patch)
treed8ed4e74e470d2c9b9bf9ad3d4ad0829dc4da0ba /src/glsl/pp/sl_pp_extension.c
parent068596c9a7e8d330ffdff8ad8700bd6093b5bdea (diff)
glsl/pp: Add sl_pp_context_add_extension().
This way third parties are able to add supported extension strings.
Diffstat (limited to 'src/glsl/pp/sl_pp_extension.c')
-rw-r--r--src/glsl/pp/sl_pp_extension.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/src/glsl/pp/sl_pp_extension.c b/src/glsl/pp/sl_pp_extension.c
index 4148fd9a5a..67b24404d4 100644
--- a/src/glsl/pp/sl_pp_extension.c
+++ b/src/glsl/pp/sl_pp_extension.c
@@ -28,23 +28,42 @@
#include <stdlib.h>
#include <string.h>
#include "sl_pp_process.h"
+#include "sl_pp_public.h"
int
+sl_pp_context_add_extension(struct sl_pp_context *context,
+ const char *name,
+ const char *name_string)
+{
+ struct sl_pp_extension ext;
+
+ if (context->num_extensions == SL_PP_MAX_EXTENSIONS) {
+ return -1;
+ }
+
+ ext.name = sl_pp_context_add_unique_str(context, name);
+ if (ext.name == -1) {
+ return -1;
+ }
+
+ ext.name_string = sl_pp_context_add_unique_str(context, name_string);
+ if (ext.name_string == -1) {
+ return -1;
+ }
+
+ context->extensions[context->num_extensions++] = ext;
+ return 0;
+}
+
+int
sl_pp_process_extension(struct sl_pp_context *context,
const struct sl_pp_token_info *input,
unsigned int first,
unsigned int last,
struct sl_pp_process_state *state)
{
- int extensions[] = {
- context->dict.all,
- context->dict._GL_ARB_draw_buffers,
- context->dict._GL_ARB_texture_rectangle,
- -1
- };
int extension_name = -1;
- int *ext;
int behavior = -1;
struct sl_pp_token_info out;
@@ -59,11 +78,17 @@ sl_pp_process_extension(struct sl_pp_context *context,
}
/* Make sure the extension is supported. */
- out.data.extension = -1;
- for (ext = extensions; *ext != -1; ext++) {
- if (extension_name == *ext) {
- out.data.extension = extension_name;
- break;
+ if (extension_name == context->dict.all) {
+ out.data.extension = extension_name;
+ } else {
+ unsigned int i;
+
+ out.data.extension = -1;
+ for (i = 0; i < context->num_extensions; i++) {
+ if (extension_name == context->extensions[i].name_string) {
+ out.data.extension = extension_name;
+ break;
+ }
}
}