#define SL_PP_MAX_ERROR_MSG 1024
+#define SL_PP_MAX_EXTENSIONS 16
+
+struct sl_pp_extension {
+ int name; /*< VENDOR_extension_name */
+ int name_string; /*< GL_VENDOR_extension_name */
+};
+
struct sl_pp_context {
char *cstr_pool;
unsigned int cstr_pool_max;
struct sl_pp_macro *macro;
struct sl_pp_macro **macro_tail;
+ struct sl_pp_extension extensions[SL_PP_MAX_EXTENSIONS];
+ unsigned int num_extensions;
+
unsigned int if_stack[SL_PP_MAX_IF_NESTING];
unsigned int if_ptr;
unsigned int if_value;
sl_pp_dict_init(struct sl_pp_context *context)
{
ADD_NAME(context, all);
- ADD_NAME_STR(context, _GL_ARB_draw_buffers, "GL_ARB_draw_buffers");
- ADD_NAME_STR(context, _GL_ARB_texture_rectangle, "GL_ARB_texture_rectangle");
ADD_NAME(context, require);
ADD_NAME(context, enable);
#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 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;
}
/* 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;
+ }
}
}
return 0;
}
+ /* Replace extension names with 1.
+ */
+ for (j = 0; j < context->num_extensions; j++) {
+ if (macro_name == context->extensions[j].name) {
+ if (!mute && _out_number(context, state, 1)) {
+ return -1;
+ }
+ (*pi)++;
+ return 0;
+ }
+ }
+
/* TODO: For FEATURE_es2_glsl, expand to 1 the following symbols.
* GL_ES
* GL_FRAGMENT_PRECISION_HIGH