Commits

yotis  committed 3d7bd9f

Updated generator scripts for new specification syntax

  • Participants
  • Parent commits 1670fc4

Comments (0)

Files changed (5)

File generator/glxx.py

 GLXX_EXPORT bool has_gl_arb_imaging_compatibility() { return glxxIsExtensionSupported("GL_ARB_imaging"); }
 GLXX_EXPORT bool has_gl_arb_imaging_core() { return glxxIsExtensionSupported("GL_ARB_imaging"); }
 
+GLXX_EXPORT bool has_gl_arb_robustness_compatibility() { return glxxIsExtensionSupported("GL_ARB_robustness"); }
+GLXX_EXPORT bool has_gl_arb_robustness_core() { return glxxIsExtensionSupported("GL_ARB_robustness"); }
+
 #if defined(_WIN32) || defined(WIN32)
 #pragma pop_macro("MemoryBarrier")
 #endif

File generator/include_proto/glxx/gl_arb_robustness_compatibility.h

+#ifndef GL_ARB_ROBUSTNESS_COMPATIBILITY
+#define GL_ARB_ROBUSTNESS_COMPATIBILITY
+
+#include "private/gl_arb_robustness.h"
+#include "private/gl_arb_robustness_deprecated.h"
+
+namespace gl_arb_robustness_compatibility
+{
+    using namespace gl_arb_robustness;
+    using namespace gl_arb_robustness_deprecated;
+}
+
+GLXX_EXPORT bool has_gl_arb_robustness_compatibility();
+GLXX_EXPORT bool load_gl_arb_robustness_compatibility();
+
+#endif

File generator/include_proto/glxx/gl_arb_robustness_core.h

+#ifndef GL_ARB_ROBUSTNESS_CORE
+#define GL_ARB_ROBUSTNESS_CORE
+
+#include "private/gl_arb_robustness.h"
+
+namespace gl_arb_robustness_core
+{
+    using namespace gl_arb_robustness;
+}
+
+GLXX_EXPORT bool has_gl_arb_robustness_core();
+GLXX_EXPORT bool load_gl_arb_robustness_core();
+
+#endif

File generator/parse.py

 
 def parse_enumext_spec(filename, prefix='', include_directory=''):
     re_empty_line = re.compile(r"^$")
-    re_commect = re.compile(r"^#.*$")
+    re_comment = re.compile(r"^#.*$")
     re_version_begin = re.compile(r"^(?P<version>VERSION_\d_\d) enum:\w*$")
     re_version_deprecated_begin = re.compile(r"^(?P<version>VERSION_\d_\d_DEPRECATED) enum:\w*$")
     re_section_begin = re.compile(r"^(?P<extension>\w+) enum:\w*$")
     re_enum = re.compile(r"^\t(?P<name>\w+)\s+= (?P<value>\w+)")
     re_use = re.compile(r"^\tuse (?P<section>\w+)\s+(?P<name>\w+)")
     re_hex_or_number = re.compile(r"^(0x[\dA-Fa-f]+|\d+)\w*$")
+    re_profile_compatibility = re.compile(r"profile: compatibility")
     
     blocks = {}
     block_list = []
         for line in f_in:
             if re_empty_line.search(line):
                 continue 
-            if re_commect.search(line):
+            if re_comment.search(line):
                 continue
-            #1. Check for deprecated version section
-            m = re_version_deprecated_begin.search(line)
+            #1. Check for compatibility profile
+            m = re_profile_compatibility.search(line)
             if m:
-                current_block = m.group('version')
+                current_block = current_block + '_DEPRECATED'
                 if not blocks.has_key(current_block):
                     block_list.append(current_block)
                 blocks[current_block] = EnumBlock('version_deprecated')
     blocks_dict = {}
     for block_name in block_list:
         priv = False
-        if block_name + '_DEPRECATED' in block_list or block_name.endswith('_DEPRECATED') or block_name.startswith('VERSION'):
+        if block_name + '_DEPRECATED' in block_list or block_name.endswith('_DEPRECATED') or block_name.startswith('VERSION') or block_name == 'ARB_robustness':
             block_filename = '../include/%s/private/%s%s.h' % (include_directory, prefix.lower(), block_name.lower())
             priv = True
         else:
     re_return = re.compile(r"\s+return\s+(?P<type>\w+)$")
     re_param = re.compile(r"\s*param\s+(?P<name>\w+)\s+(?P<type>\w+)\s+(?P<direction>(in|out))\s+(?P<dereference>(array|value|reference))")
     re_category = re.compile(r"\s+category\s+(?P<category>\w+)")
-    re_newcategory = re.compile(r"newcateg(or|ro)y:\s+(?P<category>\w+)") # (or|ro) .. spec bug
+    re_profile = re.compile(r"\s+profile\s+(?P<profile>\w+)")
+    re_newcategory = re.compile(r"newcategory:\s+(?P<category>\w+)")
     re_version = re.compile(r"\s+version\s+(?P<version>\w+)")
-    re_deprecated = re.compile(r"\s+deprecated\s+(?P<version>\w+)")
+    re_deprecated = re.compile(r"\s+deprecated\s+(?P<version>.+)")
     re_passthrough = re.compile(r"^passthru:\s*(?P<text>.+)$")
     re_passend = re.compile(r"passend:\s*(?P<text>.+)$")
     re_parse_version = re.compile(r"VERSION_(?P<major>\d)_(?P<minor>\d)")
                 if not len(categories):
                     passthrus['first'].append(line)
                 else:
-                    passthrus[categories[-1]].append(line)
+                    if categories[-1].startswith('VERSION_'):
+                        passthrus[categories[-1].rstrip('_DEPRECATED')].append(line)
+                    else:
+                        passthrus[categories[-1]].append(line)
                 continue
             # function
             m = re_function.match(line)
             if m:
                 category = m.group('category')
                 if category == 'VERSION_1_0': category = 'VERSION_1_1'
-                elif category == 'VERSION_1_0_DEPRECATED': category = 'VERSION_1_1_DEPRECATED'
                 elif category == 'SGIX_texture_select' : category = 'SGIS_texture_select' #bypass gl.spec bug
                 functions[-1].category = category
                 if not len(categories):
                     categories.append(category)
-                #if categories[-1] != category:
                 if category not in categories:
                     categories.append(category)
-                    passthrus[categories[-1]] = []
-                    passends[categories[-1]] = []
+                    passthrus[category] = []
+                    passends[category] = []
                 if category.startswith('VERSION_'):
-                    if category.endswith('_DEPRECATED'):
-                        if category not in deprecated_versions:
-                            deprecated_versions.append(category)
-                    else:
-                        if category not in versions:
-                            versions.append(category)
+                    if category not in versions:
+                        versions.append(category)
+                continue
+            # profile
+            m = re_profile.match(line)
+            if m:
+                profile = m.group('profile')
+                if profile == 'compatibility':
+                    functions[-1].deprecated = '??'
+                    if not functions[-1].category.endswith('_DEPRECATED'):
+                        functions[-1].category = functions[-1].category + '_DEPRECATED'
+                    if functions[-1].category not in categories:
+                        categories.append(functions[-1].category)
+                        passthrus[functions[-1].category] = []
+                        passends[functions[-1].category] = []
+                    if functions[-1].category.startswith('VERSION_'):
+                        if functions[-1].category not in versions:
+                            versions.append(functions[-1].category)
                 continue
             # version
             m = re_version.match(line)
             if m:
                 functions[-1].version = m.group('version')
                 continue
-            # version deprecated
+            # deprecated
             m = re_deprecated.match(line)
             if m:
                 functions[-1].deprecated = m.group('version')
+                '''
+                if not functions[-1].category.endswith('_DEPRECATED'):
+                    functions[-1].category = functions[-1].category + '_DEPRECATED'
+                if functions[-1].category not in categories:
+                    categories.append(functions[-1].category)
+                    passthrus[functions[-1].category] = []
+                    passends[functions[-1].category] = []
+                if functions[-1].category.startswith('VERSION_'):
+                    if functions[-1].category not in versions:
+                        versions.append(functions[-1].category)
+                '''
                 continue
             # newcategory
             m = re_newcategory.match(line)
             if m:
                 category = m.group('category')
                 if category == 'VERSION_1_0': category = 'VERSION_1_1'
-                elif category == 'VERSION_1_0_DEPRECATED': category = 'VERSION_1_1_DEPRECATED'
                 elif category == 'SGIX_texture_select' : category = 'SGIS_texture_select' #bypass gl.spec bug
                 if category not in categories:
                     categories.append(category)
-                    passthrus[categories[-1]] = []
-                    passends[categories[-1]] = []
+                    passthrus[category] = []
+                    passends[category] = []
                 if category.startswith('VERSION_'):
-                    if category.endswith('_DEPRECATED'):
-                        if category not in deprecated_versions:
-                            deprecated_versions.append(category)
-                    else:
-                        if category not in versions:
-                            versions.append(category)
+                    if category not in versions:
+                        versions.append(category)
                 continue
             # passend
             m = re_passend.match(line)
             unprocessed_lines.append(line)
     
 
+    # dump all
+    with open('dump_%s.txt' % prefix.lower(), 'w') as f_out:
+        for category in categories:
+            f_out.write('%s\n' % category)
+            category_functions = [f for f in functions if f.category == category]
+            for f in category_functions:
+                if f.deprecated:
+                    f_out.write('\t(%s) %s\n' % (f.deprecated, f.name))
+                else:
+                    f_out.write('\t%s\n' % f.name)
+            if passthrus.has_key(category):
+                for p in passthrus[category]:
+                    f_out.write('%s' % p)
+            f_out.write('\n')
+
     with open('unprocessed_%s.spec.txt' % prefix.lower(), 'w') as f_out:
         f_out.write(''.join(unprocessed_lines))
     
         # Get the passthrus of this category
         if passthrus.has_key(category):
             for p in passthrus[category]:
-                passthru_categories = [c for c in categories if c in p and c != category]
-                for stripped in passthru_categories:
-                    stripped_category_functions = [f for f in functions if f.category == stripped]
+                stripped_p = p.lstrip('passthru: /* ').rstrip(' */\n')
+                stripped_p = re.sub('\(.+\)','', stripped_p).strip()
+                print('sttrrriped:|%s|' % stripped_p)
+                passthru_categories = [c for c in categories if c == stripped_p and c != category]
+                for pc in passthru_categories:
+                    stripped_category_functions = [f for f in functions if f.category == pc]
                     for cf in stripped_category_functions:
+                        print('  Adding %s in %s (%s)' % (cf.name, category, pc))
                         category_functions.append(cf)
                             
         # Get all the functions of this category
             del categ_file_dict[category]
         
         # Write the functions to the appropriate header.
+        has_deprecated_functions = False
+        for f in category_functions:
+            if f.deprecated:
+                has_deprecated_functions = True
+        #if has_deprecated_functions:
         if category + '_DEPRECATED' in categories or category.endswith('_DEPRECATED') or category.startswith('VERSION'):
             category_filename = '../include/%sxx/private/%s_%s.h' % (prefix, prefix.lower(), category.lower())
         else:
             category_filename = '../include/%sxx/%s_%s.h' % (prefix, prefix.lower(), category.lower())
 
-        # Special case for this extension .. maybe check if file is in /private/ to fix this?
-        if category in ('ARB_framebuffer_object', 'ARB_imaging'):
+        # Special case for these extensions ..
+        if category in ('ARB_framebuffer_object', 'ARB_imaging', 'ARB_robustness'):
             category_filename = '../include/%sxx/private/%s_%s.h' % (prefix, prefix.lower(), category.lower())
 
         # Unknown blocks to glenumext.spec.

File include/glxx/gl_arb_robustness.h

-#ifndef GL_ARB_robustness
-#define GL_ARB_robustness
-
-#include "private/glxx.h"
-
-#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004
-#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
-#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253
-#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254
-#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255
-#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define GL_NO_RESET_NOTIFICATION_ARB 0x8261
-#define GL_NO_ERROR 0
-
-namespace gl_arb_robustness
-{
-    GLXX_EXPORT GLenum glGetGraphicsResetStatusARB();
-    GLXX_EXPORT void glGetnMapdvARB(GLenum target, GLenum query, GLsizei bufSize, GLdouble* v);
-    GLXX_EXPORT void glGetnMapfvARB(GLenum target, GLenum query, GLsizei bufSize, GLfloat* v);
-    GLXX_EXPORT void glGetnMapivARB(GLenum target, GLenum query, GLsizei bufSize, GLint* v);
-    GLXX_EXPORT void glGetnPixelMapfvARB(GLenum map, GLsizei bufSize, GLfloat* values);
-    GLXX_EXPORT void glGetnPixelMapuivARB(GLenum map, GLsizei bufSize, GLuint* values);
-    GLXX_EXPORT void glGetnPixelMapusvARB(GLenum map, GLsizei bufSize, GLushort* values);
-    GLXX_EXPORT void glGetnPolygonStippleARB(GLsizei bufSize, GLubyte* pattern);
-    GLXX_EXPORT void glGetnColorTableARB(GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid* table);
-    GLXX_EXPORT void glGetnConvolutionFilterARB(GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid* image);
-    GLXX_EXPORT void glGetnSeparableFilterARB(GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid* row, GLsizei columnBufSize, GLvoid* column, GLvoid* span);
-    GLXX_EXPORT void glGetnHistogramARB(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid* values);
-    GLXX_EXPORT void glGetnMinmaxARB(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid* values);
-    GLXX_EXPORT void glGetnTexImageARB(GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid* img);
-    GLXX_EXPORT void glReadnPixelsARB(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid* data);
-    GLXX_EXPORT void glGetnCompressedTexImageARB(GLenum target, GLint lod, GLsizei bufSize, GLvoid* img);
-    GLXX_EXPORT void glGetnUniformfvARB(GLuint program, GLint location, GLsizei bufSize, GLfloat* params);
-    GLXX_EXPORT void glGetnUniformivARB(GLuint program, GLint location, GLsizei bufSize, GLint* params);
-    GLXX_EXPORT void glGetnUniformuivARB(GLuint program, GLint location, GLsizei bufSize, GLuint* params);
-    GLXX_EXPORT void glGetnUniformdvARB(GLuint program, GLint location, GLsizei bufSize, GLdouble* params);
-}
-
-#ifdef GLXX_NAMESPACE_INJECTION
-using namespace gl_arb_robustness;
-#endif
-
-GLXX_EXPORT bool has_gl_arb_robustness();
-GLXX_EXPORT bool load_gl_arb_robustness();
-
-#endif