138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#!/usr/bin/env python 238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# Copyright (C) 2012 Intel Corporation 438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# 538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# Permission is hereby granted, free of charge, to any person obtaining a 638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# copy of this software and associated documentation files (the "Software"), 738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# to deal in the Software without restriction, including without limitation 838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# the rights to use, copy, modify, merge, publish, distribute, sublicense, 938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# and/or sell copies of the Software, and to permit persons to whom the 1038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# Software is furnished to do so, subject to the following conditions: 1138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# 1238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# The above copyright notice and this permission notice (including the next 1338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# paragraph) shall be included in all copies or substantial portions of the 1438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# Software. 1538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# 1638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 2238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# IN THE SOFTWARE. 2338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 2438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# This script generates the file api_exec.c, which contains 25d44014953835e9180eeb54a7969470396d7f3fd0Jordan Justen# _mesa_initialize_exec_table(). It is responsible for populating all 2638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry# entries in the "exec" dispatch table that aren't dynamic. 2738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 2879c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Bakerimport argparse 2938a1039a427d73ad959cc978d44fcf8c21388868Paul Berryimport collections 3038a1039a427d73ad959cc978d44fcf8c21388868Paul Berryimport license 3138a1039a427d73ad959cc978d44fcf8c21388868Paul Berryimport gl_XML 3279c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Bakerimport sys 33f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanickimport apiexec 3438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 3538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 3638a1039a427d73ad959cc978d44fcf8c21388868Paul Berryexec_flavor_map = { 3738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 'dynamic': None, 3838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 'mesa': '_mesa_', 3938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 'skip': None, 4038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry } 4138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 4238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 4338a1039a427d73ad959cc978d44fcf8c21388868Paul Berryheader = """/** 4438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry * \\file api_exec.c 4538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry * Initialize dispatch table. 4638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry */ 4738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 4838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 4938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/accum.h" 5038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/api_loopback.h" 5138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/api_exec.h" 5238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/arbprogram.h" 5338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/atifragshader.h" 5438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/attrib.h" 5538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/blend.h" 56bfcb9bb20451aa7c74d8769ae043fb11503e8453Brian Paul#include "main/blit.h" 5738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/bufferobj.h" 5838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/arrayobj.h" 593b81c998a214a2ad7a4a712577277b1fc7b9be4eIlia Mirkin#include "main/bbox.h" 6038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/buffers.h" 6138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/clear.h" 6238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/clip.h" 6338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/colortab.h" 6479134cb51609724cc4d94ade12dc52a09e2e91dbPaul Berry#include "main/compute.h" 6538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/condrender.h" 6638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/context.h" 6738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/convolve.h" 6841b6460e08bf878ec3372937f63bef2a7b63c484Jason Ekstrand#include "main/copyimage.h" 6938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/depth.h" 705fdbfb8d6fa2e1521cf2f60e80ac571a37ab22a2Brian Paul#include "main/debug_output.h" 7138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/dlist.h" 7238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/drawpix.h" 7338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/drawtex.h" 7438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/rastpos.h" 7538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/enable.h" 7638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/errors.h" 7738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/es1_conversion.h" 7838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/eval.h" 7938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/get.h" 8038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/feedback.h" 8138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/fog.h" 8238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/fbobject.h" 8338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/framebuffer.h" 843abd4f4d90c5827f74509c1f507ed71aa7be9a15Brian Paul#include "main/genmipmap.h" 8538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/hint.h" 8638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/histogram.h" 8738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/imports.h" 8838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/light.h" 8938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/lines.h" 9038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/matrix.h" 9138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/multisample.h" 929405be4add90b55b078acd91f404ce2914afb405Timothy Arceri#include "main/objectlabel.h" 931aff899a874abddc2d79e595242a233e874e4a96Brian Paul#include "main/objectpurge.h" 94b2e327e08f8519da131dd382adcc99240d433404Kenneth Graunke#include "main/performance_monitor.h" 9573b78f9c9f86dd38fb165f4730aeac9519635b07Gregory Hainaut#include "main/pipelineobj.h" 9638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/pixel.h" 9738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/pixelstore.h" 9838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/points.h" 9938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/polygon.h" 100b297fc27aa93c4af4cf8ecf9702fd0b95d2c4f9aTapani Pälli#include "main/program_resource.h" 10138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/querymatrix.h" 10238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/queryobj.h" 10338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/readpix.h" 10438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/samplerobj.h" 10538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/scissor.h" 10638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/stencil.h" 10738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/texenv.h" 10838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/texgetimage.h" 10938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/teximage.h" 11038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/texgen.h" 11138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/texobj.h" 11238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/texparam.h" 11338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/texstate.h" 11438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/texstorage.h" 11583d2f9db2929781d7d4b182355c872a7cbbcaeecFrancisco Jerez#include "main/barrier.h" 116d77d2af20a978972d74dcaa6c1099be02578f247Courtney Goeltzenleuchter#include "main/textureview.h" 11738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/transformfeedback.h" 11838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/mtypes.h" 11938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/varray.h" 12038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/viewport.h" 12138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/shaderapi.h" 122bcc49e17ffb76110a05130116b15904db6a0278cFrancisco Jerez#include "main/shaderimage.h" 12338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/uniforms.h" 12438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/syncobj.h" 125bda540d2357f69a63dcf16550e178f803682d6ceIan Romanick#include "main/formatquery.h" 12638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry#include "main/dispatch.h" 12780964226e9b8a05c39157f9305c06c0b2861e080Christian König#include "main/vdpau.h" 12849993a1a9dc34b78ccd345b91087385917a40138Brian Paul#include "vbo/vbo.h" 12938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 13038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 13138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry/** 132d44014953835e9180eeb54a7969470396d7f3fd0Jordan Justen * Initialize a context's exec table with pointers to Mesa's supported 133d44014953835e9180eeb54a7969470396d7f3fd0Jordan Justen * GL functions. 13438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry * 135d44014953835e9180eeb54a7969470396d7f3fd0Jordan Justen * This function depends on ctx->Version. 13638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry * 13738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry * \param ctx GL context to which \c exec belongs. 13838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry */ 139d44014953835e9180eeb54a7969470396d7f3fd0Jordan Justenvoid 140d44014953835e9180eeb54a7969470396d7f3fd0Jordan Justen_mesa_initialize_exec_table(struct gl_context *ctx) 14138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry{ 14238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry struct _glapi_table *exec; 14338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 144d44014953835e9180eeb54a7969470396d7f3fd0Jordan Justen exec = ctx->Exec; 145d44014953835e9180eeb54a7969470396d7f3fd0Jordan Justen assert(exec != NULL); 14638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 1471358f3a905448f6fb546aba951e317f743a83c76Jordan Justen assert(ctx->Version > 0); 14849993a1a9dc34b78ccd345b91087385917a40138Brian Paul 14949993a1a9dc34b78ccd345b91087385917a40138Brian Paul vbo_initialize_exec_dispatch(ctx, exec); 15038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry""" 15138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 15238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 15338a1039a427d73ad959cc978d44fcf8c21388868Paul Berryfooter = """ 15438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry} 15538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry""" 15638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 15738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 15838a1039a427d73ad959cc978d44fcf8c21388868Paul Berryclass PrintCode(gl_XML.gl_print_base): 15938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 16038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry def __init__(self): 16138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry gl_XML.gl_print_base.__init__(self) 16238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 16338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry self.name = 'gl_genexec.py' 16438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry self.license = license.bsd_license_template % ( 16538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 'Copyright (C) 2012 Intel Corporation', 16638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 'Intel Corporation') 16738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 16838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry def printRealHeader(self): 16938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry print header 17038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 17138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry def printRealFooter(self): 17238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry print footer 17338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 17438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry def printBody(self, api): 17538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry # Collect SET_* calls by the condition under which they should 17638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry # be called. 17738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry settings_by_condition = collections.defaultdict(lambda: []) 17838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry for f in api.functionIterateAll(): 17938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry if f.exec_flavor not in exec_flavor_map: 18038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry raise Exception( 18138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 'Unrecognized exec flavor {0!r}'.format(f.exec_flavor)) 18238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry condition_parts = [] 183f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if f.name in apiexec.functions: 184f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick ex = apiexec.functions[f.name] 185f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick unconditional_count = 0 186f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick 187f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if ex.compatibility is not None: 188dbd6135bc1ba285128ab991c03c4df6fbd6fefe8Paul Berry condition_parts.append('ctx->API == API_OPENGL_COMPAT') 189f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick unconditional_count += 1 190f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick 191f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if ex.core is not None: 192f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick condition_parts.append('ctx->API == API_OPENGL_CORE') 193f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick unconditional_count += 1 194f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick 195f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if ex.es1 is not None: 196f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick condition_parts.append('ctx->API == API_OPENGLES') 197f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick unconditional_count += 1 198f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick 199f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if ex.es2 is not None: 200f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if ex.es2 > 20: 201f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick condition_parts.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(ex.es2)) 202f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick else: 203f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick condition_parts.append('ctx->API == API_OPENGLES2') 204f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick unconditional_count += 1 205f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick 206f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick # If the function is unconditionally available in all four 207f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick # APIs, then it is always available. Replace the complex 208f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick # tautology condition with "true" and let GCC do the right 209f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick # thing. 210f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if unconditional_count == 4: 211f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick condition_parts = ['true'] 212f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick else: 213f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if f.desktop: 214f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if f.deprecated: 215f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick condition_parts.append('ctx->API == API_OPENGL_COMPAT') 216f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick else: 217f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick condition_parts.append('_mesa_is_desktop_gl(ctx)') 218f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if 'es1' in f.api_map: 219f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick condition_parts.append('ctx->API == API_OPENGLES') 220f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if 'es2' in f.api_map: 221f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick if f.api_map['es2'] > 2.0: 222f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick condition_parts.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(int(f.api_map['es2'] * 10))) 223f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick else: 224f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick condition_parts.append('ctx->API == API_OPENGLES2') 225f20899b7276b73e1b60c3ed8d8abdf959e787c0cIan Romanick 22638a1039a427d73ad959cc978d44fcf8c21388868Paul Berry if not condition_parts: 22738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry # This function does not exist in any API. 22838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry continue 22938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry condition = ' || '.join(condition_parts) 23038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry prefix = exec_flavor_map[f.exec_flavor] 23138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry if prefix is None: 23238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry # This function is not implemented, or is dispatched 23338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry # dynamically. 23438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry continue 23538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry settings_by_condition[condition].append( 23655b81ff56b89ef21747e022896674dd024b9ec7ePaul Berry 'SET_{0}(exec, {1}{0});'.format(f.name, prefix, f.name)) 23738a1039a427d73ad959cc978d44fcf8c21388868Paul Berry # Print out an if statement for each unique condition, with 23838a1039a427d73ad959cc978d44fcf8c21388868Paul Berry # the SET_* calls nested inside it. 23938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry for condition in sorted(settings_by_condition.keys()): 24038a1039a427d73ad959cc978d44fcf8c21388868Paul Berry print ' if ({0}) {{'.format(condition) 24138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry for setting in sorted(settings_by_condition[condition]): 24238a1039a427d73ad959cc978d44fcf8c21388868Paul Berry print ' {0}'.format(setting) 24338a1039a427d73ad959cc978d44fcf8c21388868Paul Berry print ' }' 24438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 24538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 24679c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Bakerdef _parser(): 24779c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Baker """Parse arguments and return namespace.""" 24879c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Baker parser = argparse.ArgumentParser() 24979c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Baker parser.add_argument('-f', 25079c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Baker dest='filename', 25179c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Baker default='gl_and_es_API.xml', 25279c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Baker help='an xml file describing an API') 25379c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Baker return parser.parse_args() 25438a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 25538a1039a427d73ad959cc978d44fcf8c21388868Paul Berry 25667d3ec0bb8f6a8c918b371ed03ef21814899f07dDylan Bakerdef main(): 25767d3ec0bb8f6a8c918b371ed03ef21814899f07dDylan Baker """Main function.""" 25879c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Baker args = _parser() 25938a1039a427d73ad959cc978d44fcf8c21388868Paul Berry printer = PrintCode() 26079c4e595bce563d6075fed176c2256bf2e7e99a5Dylan Baker api = gl_XML.parse_GL_API(args.filename) 26138a1039a427d73ad959cc978d44fcf8c21388868Paul Berry printer.Print(api) 26267d3ec0bb8f6a8c918b371ed03ef21814899f07dDylan Baker 26367d3ec0bb8f6a8c918b371ed03ef21814899f07dDylan Baker 26467d3ec0bb8f6a8c918b371ed03ef21814899f07dDylan Bakerif __name__ == '__main__': 26567d3ec0bb8f6a8c918b371ed03ef21814899f07dDylan Baker main() 266