mapi/glapi: Remove glX_doc.py.
[mesa.git] / src / mapi / glapi / gen / gl_XML.py
index f956730f2e07c68781046b6349ac78d470b10a17..3bbc794398f27356490293600a06d915ada0ef72 100644 (file)
@@ -25,6 +25,7 @@
 # Authors:
 #    Ian Romanick <idr@us.ibm.com>
 
+from decimal import Decimal
 import libxml2
 import re, sys, string
 import typeexpr
@@ -593,7 +594,6 @@ class gl_parameter(object):
             return self.type_expr.format_string()
 
 
-
 class gl_function( gl_item ):
     def __init__(self, element, context):
         self.context = context
@@ -605,6 +605,27 @@ class gl_function( gl_item ):
         self.offset = -1
         self.initialized = 0
         self.images = []
+        self.exec_flavor = 'mesa'
+        self.desktop = True
+        self.deprecated = None
+
+        # self.entry_point_api_map[name][api] is a decimal value
+        # indicating the earliest version of the given API in which
+        # each entry point exists.  Every entry point is included in
+        # the first level of the map; the second level of the map only
+        # lists APIs which contain the entry point in at least one
+        # version.  For example,
+        # self.entry_point_api_map['ClipPlanex'] == { 'es1':
+        # Decimal('1.1') }.
+        self.entry_point_api_map = {}
+
+        # self.api_map[api] is a decimal value indicating the earliest
+        # version of the given API in which ANY alias for the function
+        # exists.  The map only lists APIs which contain the function
+        # in at least one version.  For example, for the ClipPlanex
+        # function, self.entry_point_api_map == { 'es1':
+        # Decimal('1.1') }.
+        self.api_map = {}
 
         self.assign_offset = 0
 
@@ -634,13 +655,36 @@ class gl_function( gl_item ):
             self.static_entry_points.append(name)
 
         self.entry_points.append( name )
+
+        self.entry_point_api_map[name] = {}
+        for api in ('es1', 'es2'):
+            version_str = element.nsProp(api, None)
+            assert version_str is not None
+            if version_str != 'none':
+                version_decimal = Decimal(version_str)
+                self.entry_point_api_map[name][api] = version_decimal
+                if api not in self.api_map or \
+                        version_decimal < self.api_map[api]:
+                    self.api_map[api] = version_decimal
+
+        exec_flavor = element.nsProp('exec', None)
+        if exec_flavor:
+            self.exec_flavor = exec_flavor
+
+        deprecated = element.nsProp('deprecated', None)
+        if deprecated != 'none':
+            self.deprecated = Decimal(deprecated)
+
+        if not is_attr_true(element, 'desktop'):
+            self.desktop = False
+
         if alias:
             true_name = alias
         else:
             true_name = name
 
-            # Only try to set the offset when a non-alias
-            # entry-point is being processes.
+            # Only try to set the offset when a non-alias entry-point
+            # is being processed.
 
             offset = element.nsProp( "offset", None )
             if offset:
@@ -738,8 +782,11 @@ class gl_function( gl_item ):
         return self.images
 
 
-    def parameterIterator(self):
-        return self.parameters.__iter__();
+    def parameterIterator(self, name = None):
+        if name is not None:
+            return self.entry_point_parameters[name].__iter__();
+        else:
+            return self.parameters.__iter__();
 
 
     def get_parameter_string(self, entrypoint = None):
@@ -755,6 +802,8 @@ class gl_function( gl_item ):
         comma = ""
 
         for p in self.parameterIterator():
+            if p.is_padding:
+                continue
             p_string = p_string + comma + p.name
             comma = ", "
 
@@ -779,6 +828,22 @@ class gl_function( gl_item ):
         else:
             return "_dispatch_stub_%u" % (self.offset)
 
+    def entry_points_for_api_version(self, api, version = None):
+        """Return a list of the entry point names for this function
+        which are supported in the given API (and optionally, version).
+
+        Use the decimal.Decimal type to precisely express non-integer
+        versions.
+        """
+        result = []
+        for entry_point, api_to_ver in self.entry_point_api_map.iteritems():
+            if api not in api_to_ver:
+                continue
+            if version is not None and version < api_to_ver[api]:
+                continue
+            result.append(entry_point)
+        return result
+
 
 class gl_item_factory(object):
     """Factory to create objects derived from gl_item."""
@@ -825,6 +890,19 @@ class gl_api(object):
 
         self.functions_by_name = functions_by_name
 
+    def filter_functions_by_api(self, api, version = None):
+        """Filter out entry points not in the given API (or
+        optionally, not in the given version of the given API).
+        """
+        functions_by_name = {}
+        for func in self.functions_by_name.itervalues():
+            entry_points = func.entry_points_for_api_version(api, version)
+            if entry_points:
+                func.filter_entry_points(entry_points)
+                functions_by_name[func.name] = func
+
+        self.functions_by_name = functions_by_name
+
     def process_element(self, doc):
         element = doc.children
         while element.type != "element" or element.name != "OpenGLAPI":