c85184d05123c56f645642c3fe0206173d165074
3 # (C) Copyright IBM Corporation 2004
6 # Permission is hereby granted, free of charge, to any person obtaining a
7 # copy of this software and associated documentation files (the "Software"),
8 # to deal in the Software without restriction, including without limitation
9 # on the rights to use, copy, modify, merge, publish, distribute, sub
10 # license, and/or sell copies of the Software, and to permit persons to whom
11 # the Software is furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice (including the next
14 # paragraph) shall be included in all copies or substantial portions of the
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 # IBM AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 # Ian Romanick <idr@us.ibm.com>
28 from xml
.sax
import saxutils
29 from xml
.sax
import make_parser
30 from xml
.sax
.handler
import feature_namespaces
38 print """# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
39 # define PURE __attribute__((pure))
45 print """# if defined(__i386__) && defined(__GNUC__)
46 # define FASTCALL __attribute__((fastcall))
51 def printVisibility(S
, s
):
52 print """# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
53 # define %s __attribute__((visibility("%s")))
56 # endif""" % (S
, s
, S
)
59 print """# if defined(__GNUC__)
60 # define NOINLINE __attribute__((noinline))
66 class glXItemFactory(gl_XML
.glItemFactory
):
67 """Factory to create GLX protocol oriented objects derived from glItem."""
69 def create(self
, context
, name
, attrs
):
70 if name
== "function":
71 return glXFunction(context
, name
, attrs
)
73 return glXEnum(context
, name
, attrs
)
75 return glXParameter(context
, name
, attrs
)
77 return gl_XML
.glItemFactory
.create(self
, context
, name
, attrs
)
79 class glXEnumFunction
:
80 def __init__(self
, name
):
83 # "enums" is a set of lists. The element in the set is the
84 # value of the enum. The list is the list of names for that
85 # value. For example, [0x8126] = {"POINT_SIZE_MIN",
86 # "POINT_SIZE_MIN_ARB", "POINT_SIZE_MIN_EXT",
87 # "POINT_SIZE_MIN_SGIS"}.
91 # "count" is indexed by count values. Each element of count
92 # is a list of index to "enums" that have that number of
93 # associated data elements. For example, [4] =
94 # {GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_EMISSION,
95 # GL_AMBIENT_AND_DIFFUSE} (the enum names are used here,
96 # but the actual hexadecimal values would be in the array).
101 def append(self
, count
, value
, name
):
102 if self
.enums
.has_key( value
):
103 self
.enums
[value
].append(name
)
105 if not self
.count
.has_key(count
):
106 self
.count
[count
] = []
108 self
.enums
[value
] = []
109 self
.enums
[value
].append(name
)
110 self
.count
[count
].append(value
)
113 def signature( self
):
116 for e
in self
.count
[i
]:
117 sig
+= "%04x,%u," % (e
, i
)
122 def PrintUsingTable(self
):
123 """Emit the body of the __gl*_size function using a pair
124 of look-up tables and a mask. The mask is calculated such
125 that (e & mask) is unique for all the valid values of e for
126 this function. The result of (e & mask) is used as an index
127 into the first look-up table. If it matches e, then the
128 same entry of the second table is returned. Otherwise zero
131 It seems like this should cause better code to be generated.
132 However, on x86 at least, the resulting .o file is about 20%
133 larger then the switch-statment version. I am leaving this
134 code in because the results may be different on other
135 platforms (e.g., PowerPC or x86-64)."""
142 # Determine if there is some mask M, such that M = (2^N) - 1,
143 # that will generate unique values for all of the enums.
146 for i
in [1, 2, 3, 4, 5, 6, 7, 8]:
153 if (a
& mask
) == (b
& mask
):
161 if (mask
!= 0) and (mask
< (2 * count
)):
165 for i
in range(0, mask
+ 1):
166 masked_enums
[i
] = "0";
170 for e
in self
.count
[c
]:
172 masked_enums
[i
] = '0x%04x /* %s */' % (e
, self
.enums
[e
][0])
176 print ' static const GLushort a[%u] = {' % (mask
+ 1)
177 for e
in masked_enums
:
178 print ' %s, ' % (masked_enums
[e
])
181 print ' static const GLubyte b[%u] = {' % (mask
+ 1)
182 for c
in masked_count
:
183 print ' %u, ' % (masked_count
[c
])
186 print ' const unsigned idx = (e & 0x%02xU);' % (mask
)
188 print ' return (e == a[idx]) ? (GLint) b[idx] : 0;'
193 def PrintUsingSwitch(self
):
194 """Emit the body of the __gl*_size function using a
197 print ' switch( e ) {'
200 for e
in self
.count
[c
]:
203 # There may be multiple enums with the same
204 # value. This happens has extensions are
205 # promoted from vendor-specific or EXT to
206 # ARB and to the core. Emit the first one as
207 # a case label, and emit the others as
208 # commented-out case labels.
210 for j
in self
.enums
[e
]:
212 print ' case %s:' % (j
)
215 print '/* case %s:*/' % (j
)
217 print ' return %u;' % (c
)
219 print ' default: return 0;'
223 def Print(self
, name
):
224 print 'INTERNAL PURE FASTCALL GLint'
225 print '__gl%s_size( GLenum e )' % (name
)
228 if not self
.PrintUsingTable():
229 self
.PrintUsingSwitch()
236 class glXEnum(gl_XML
.glEnum
):
237 def __init__(self
, context
, name
, attrs
):
238 gl_XML
.glEnum
.__init
__(self
, context
, name
, attrs
)
239 self
.glx_functions
= []
241 def startElement(self
, name
, attrs
):
243 n
= attrs
.get('name', None)
244 if not self
.context
.glx_enum_functions
.has_key( n
):
245 f
= glXEnumFunction( n
)
246 self
.context
.glx_enum_functions
[ f
.name
] = f
248 temp
= attrs
.get('count', None)
252 raise RuntimeError('Invalid count value "%s" for enum "%s" in function "%s" when an integer was expected.' % (temp
, self
.name
, n
))
254 self
.context
.glx_enum_functions
[ n
].append( c
, self
.value
, self
.name
)
256 gl_XML
.glEnum
.startElement(self
, context
, name
, attrs
)
260 class glXParameter(gl_XML
.glParameter
):
261 def __init__(self
, context
, name
, attrs
):
263 gl_XML
.glParameter
.__init
__(self
, context
, name
, attrs
);
266 class glXFunction(gl_XML
.glFunction
):
271 # If this is set to true, it means that GLdouble parameters should be
272 # written to the GLX protocol packet in the order they appear in the
273 # prototype. This is different from the "classic" ordering. In the
274 # classic ordering GLdoubles are written to the protocol packet first,
275 # followed by non-doubles. NV_vertex_program was the first extension
276 # to break with this tradition.
278 glx_doubles_in_order
= 0
285 def __init__(self
, context
, name
, attrs
):
286 self
.vectorequiv
= attrs
.get('vectorequiv', None)
287 self
.count_parameters
= None
290 self
.can_be_large
= 0
291 self
.reply_always_array
= 0
293 gl_XML
.glFunction
.__init
__(self
, context
, name
, attrs
)
296 def startElement(self
, name
, attrs
):
297 """Process elements within a function that are specific to GLX."""
300 self
.glx_rop
= int(attrs
.get('rop', "0"))
301 self
.glx_sop
= int(attrs
.get('sop', "0"))
302 self
.glx_vendorpriv
= int(attrs
.get('vendorpriv', "0"))
304 if attrs
.get('handcode', "false") == "true":
309 if attrs
.get('ignore', "false") == "true":
314 if attrs
.get('large', "false") == "true":
315 self
.can_be_large
= 1
317 self
.can_be_large
= 0
319 if attrs
.get('doubles_in_order', "false") == "true":
320 self
.glx_doubles_in_order
= 1
322 self
.glx_doubles_in_order
= 0
324 if attrs
.get('always_array', "false") == "true":
325 self
.reply_always_array
= 1
327 self
.reply_always_array
= 0
330 gl_XML
.glFunction
.startElement(self
, name
, attrs
)
333 def append(self
, tag_name
, p
):
334 gl_XML
.glFunction
.append(self
, tag_name
, p
)
336 if p
.is_variable_length_array():
338 elif not self
.glx_doubles_in_order
and p
.p_type
.size
== 8:
341 if p
.p_count_parameters
!= None:
342 self
.count_parameters
= p
.p_count_parameters
345 self
.counter
= p
.name
352 def variable_length_parameter(self
):
353 for param
in self
.fn_parameters
:
354 if param
.is_variable_length_array():
360 def command_payload_length(self
):
364 if p
.is_output
: continue
365 temp
= p
.size_string()
370 size_string
= size_string
+ " + __GLX_PAD(%s)" % (temp
)
372 return [size
, size_string
]
374 def command_length(self
):
375 [size
, size_string
] = self
.command_payload_length()
377 if self
.glx_rop
!= 0:
380 size
= ((size
+ 3) & ~
3)
381 return "%u%s" % (size
, size_string
)
384 def opcode_real_value(self
):
385 if self
.glx_vendorpriv
!= 0:
386 if self
.needs_reply():
391 return self
.opcode_value()
393 def opcode_value(self
):
394 if self
.glx_rop
!= 0:
396 elif self
.glx_sop
!= 0:
398 elif self
.glx_vendorpriv
!= 0:
399 return self
.glx_vendorpriv
403 def opcode_rop_basename(self
):
404 if self
.vectorequiv
== None:
407 return self
.vectorequiv
409 def opcode_name(self
):
410 if self
.glx_rop
!= 0:
411 return "X_GLrop_%s" % (self
.opcode_rop_basename())
412 elif self
.glx_sop
!= 0:
413 return "X_GLsop_%s" % (self
.name
)
414 elif self
.glx_vendorpriv
!= 0:
415 return "X_GLvop_%s" % (self
.name
)
419 def opcode_real_name(self
):
420 if self
.glx_vendorpriv
!= 0:
421 if self
.needs_reply():
422 return "X_GLXVendorPrivateWithReply"
424 return "X_GLXVendorPrivate"
426 return self
.opcode_name()
429 def return_string(self
):
430 if self
.fn_return_type
!= 'void':
431 return "return retval;"
436 def needs_reply(self
):
437 return self
.fn_return_type
!= 'void' or self
.output
!= None
440 class GlxProto(gl_XML
.FilterGLAPISpecBase
):
441 name
= "glX_proto_send.py (from Mesa)"
444 gl_XML
.FilterGLAPISpecBase
.__init
__(self
)
445 self
.factory
= glXItemFactory()
446 self
.glx_enum_functions
= {}
449 def endElement(self
, name
):
450 if name
== 'OpenGLAPI':
451 # Once all the parsing is done, we have to go back and
452 # fix-up some cross references between different
455 for k
in self
.functions
:
456 f
= self
.functions
[k
]
457 if f
.vectorequiv
!= None:
458 equiv
= self
.find_function(f
.vectorequiv
)
460 f
.glx_doubles_in_order
= equiv
.glx_doubles_in_order
461 f
.glx_rop
= equiv
.glx_rop
463 raise RuntimeError("Could not find the vector equiv. function %s for %s!" % (f
.name
, f
.vectorequiv
))
465 gl_XML
.FilterGLAPISpecBase
.endElement(self
, name
)
469 class PrintGlxProtoStubs(GlxProto
):
471 GlxProto
.__init
__(self
)
472 self
.last_category
= ""
473 self
.license
= license
.bsd_license_template
% ( "(C) Copyright IBM Corporation 2004", "IBM")
474 self
.generic_sizes
= [3, 4, 6, 8, 12, 16, 24, 32]
477 def printRealHeader(self
):
479 print '#include <GL/gl.h>'
480 print '#include "indirect.h"'
481 print '#include "glxclient.h"'
482 print '#include "size.h"'
483 print '#include <GL/glxproto.h>'
485 print '#define __GLX_PAD(n) (((n) + 3) & ~3)'
490 print '/* If the size and opcode values are known at compile-time, this will, on'
491 print ' * x86 at least, emit them with a single instruction.'
493 print '#define emit_header(dest, op, size) \\'
494 print ' do { union { short s[2]; int i; } temp; \\'
495 print ' temp.s[0] = (size); temp.s[1] = (op); \\'
496 print ' *((int *)(dest)) = temp.i; } while(0)'
498 print """static NOINLINE CARD32
499 read_reply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_array )
501 xGLXSingleReply reply;
503 (void) _XReply(dpy, (xReply *) & reply, 0, False);
505 if ((reply.size >= 1) || reply_is_always_array) {
506 const GLint bytes = (reply_is_always_array)
507 ? (4 * reply.length) : (reply.size * size);
508 const GLint extra = 4 - (bytes & 3);
510 _XRead(dpy, dest, bytes);
512 _XEatData(dpy, extra);
516 (void) memcpy( dest, &(reply.pad3), size);
523 #define X_GLXSingle 0
525 static NOINLINE GLubyte *
526 setup_single_request( __GLXcontext * gc, GLint sop, GLint cmdlen )
529 Display * const dpy = gc->currentDpy;
531 (void) __glXFlushRenderBuffer(gc, gc->pc);
533 GetReqExtra(GLXSingle, cmdlen, req);
534 req->reqType = gc->majorOpcode;
535 req->contextTag = gc->currentContextTag;
537 return (GLubyte *)(req) + sz_xGLXSingleReq;
540 static NOINLINE GLubyte *
541 setup_vendor_request( __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen )
543 xGLXVendorPrivateReq * req;
544 Display * const dpy = gc->currentDpy;
546 (void) __glXFlushRenderBuffer(gc, gc->pc);
548 GetReqExtra(GLXVendorPrivate, cmdlen, req);
549 req->reqType = gc->majorOpcode;
551 req->vendorCode = vop;
552 req->contextTag = gc->currentContextTag;
553 return (GLubyte *)(req) + sz_xGLXVendorPrivateReq;
557 for size
in self
.generic_sizes
:
558 self
.print_generic_function(size
)
561 def printFunction(self
, f
):
562 if f
.fn_offset
< 0 or f
.handcode
or f
.ignore
: return
564 if f
.glx_rop
!= 0 or f
.vectorequiv
!= None:
565 self
.printRenderFunction(f
)
566 elif f
.glx_sop
!= 0 or f
.glx_vendorpriv
!= 0:
567 self
.printSingleFunction(f
)
569 print "/* Missing GLX protocol for %s. */" % (f
.name
)
571 def print_generic_function(self
, n
):
572 print """static FASTCALL NOINLINE void
573 generic_%u_byte( GLint rop, const void * ptr )
575 __GLXcontext * const gc = __glXGetCurrentContext();
576 const GLuint cmdlen = %u;
578 emit_header(gc->pc, rop, cmdlen);
579 (void) memcpy((void *)(gc->pc + 4), ptr, %u);
581 if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
586 def common_emit_one_arg(self
, p
, offset
, pc
, indent
, adjust
):
587 if p
.is_output
: return
593 src_ptr
= "&" + p
.name
595 print '%s (void) memcpy((void *)(%s + %u), (void *)(%s), %s);' \
596 % (indent
, pc
, offset
+ adjust
, src_ptr
, p
.size_string() )
598 def common_emit_args(self
, f
, pc
, indent
, adjust
, skip_vla
):
599 # First emit all of the fixed-length 8-byte (i.e., GLdouble)
611 if p
.is_output
or p
.order
!= order
: continue
613 self
.common_emit_one_arg(p
, offset
, pc
, indent
, adjust
)
620 def common_func_print_just_header(self
, f
):
621 print '#define %s %d' % (f
.opcode_name(), f
.opcode_value())
623 print '%s' % (f
.fn_return_type
)
624 print '__indirect_gl%s(%s)' % (f
.name
, f
.get_parameter_string())
628 def common_func_print_header(self
, f
):
629 self
.common_func_print_just_header(f
)
631 print ' __GLXcontext * const gc = __glXGetCurrentContext();'
632 print ' Display * const dpy = gc->currentDpy;'
634 if f
.fn_return_type
!= 'void':
635 print ' %s retval = (%s) 0;' % (f
.fn_return_type
, f
.fn_return_type
)
637 if f
.count_parameters
!= None:
638 print ' const GLuint compsize = __gl%s_size(%s);' % (f
.name
, f
.count_parameters
)
640 print ' const GLuint cmdlen = %s;' % (f
.command_length())
642 if f
.counter
!= None:
643 print ' if (%s < 0) %s' % (f
.counter
, f
.return_string())
646 print ' if (dpy == NULL) return;'
647 print ' if ( ((gc->pc + cmdlen) > gc->bufEnd)'
648 print ' || (cmdlen > gc->maxSmallRenderCommandSize)) {'
649 print ' (void) __glXFlushRenderBuffer(gc, gc->pc);'
657 def printSingleFunction(self
, f
):
658 self
.common_func_print_header(f
)
660 print ' if (dpy != NULL) {'
662 if f
.fn_parameters
!= []:
663 pc_decl
= "GLubyte const * pc ="
667 if f
.glx_vendorpriv
!= 0:
668 print ' %s setup_vendor_request(gc, %s, %s, cmdlen);' % (pc_decl
, f
.opcode_real_name(), f
.opcode_name())
670 print ' %s setup_single_request(gc, %s, cmdlen);' % (pc_decl
, f
.opcode_name())
672 self
.common_emit_args(f
, "pc", " ", 0, 0)
676 output_size
= f
.output
.p_type
.size
677 output_str
= f
.output
.name
682 if f
.fn_return_type
!= 'void':
683 return_str
= " retval = (%s)" % (f
.fn_return_type
)
685 return_str
= " (void)"
687 if f
.reply_always_array
:
692 print " %s read_reply(gc->currentDpy, %s, %s, %s);" % (return_str
, output_size
, output_str
, aa
)
694 print ' UnlockDisplay(gc->currentDpy); SyncHandle();'
696 print ' %s' % f
.return_string()
702 def printRenderFunction(self
, f
):
703 # There is a class of GL functions that take a single pointer
704 # as a parameter. This pointer points to a fixed-size chunk
705 # of data, and the protocol for this functions is very
706 # regular. Since they are so regular and there are so many
707 # of them, special case them with generic functions. On
708 # x86, this save about 26KB in the libGL.so binary.
710 if f
.variable_length_parameter() == None and len(f
.fn_parameters
) == 1:
711 p
= f
.fn_parameters
[0]
713 [cmdlen
, size_string
] = f
.command_payload_length()
714 if cmdlen
in self
.generic_sizes
:
715 self
.common_func_print_just_header(f
)
716 print ' generic_%u_byte( %s, %s );' % (cmdlen
, f
.opcode_real_name(), p
.name
)
721 self
.common_func_print_header(f
)
724 print ' if (cmdlen <= gc->maxSmallRenderCommandSize) {'
729 print '%s emit_header(gc->pc, %s, cmdlen);' % (indent
, f
.opcode_real_name())
731 self
.common_emit_args(f
, "gc->pc", indent
, 4, 0)
732 print '%s gc->pc += cmdlen;' % (indent
)
733 print '%s if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }' % (indent
)
738 print ' const GLint op = %s;' % (f
.opcode_real_name())
739 print ' const GLuint cmdlenLarge = cmdlen + 4;'
740 print ' (void) memcpy((void *)(gc->pc + 0), (void *)(&op), 4);'
741 print ' (void) memcpy((void *)(gc->pc + 4), (void *)(&cmdlenLarge), 4);'
742 offset
= self
.common_emit_args(f
, "gc->pc", indent
, 8, 1)
744 p
= f
.variable_length_parameter()
745 print ' __glXSendLargeCommand(gc, gc->pc, %u, %s, %s);' % (offset
+ 8, p
.name
, p
.size_string())
753 class PrintGlxProtoInit_c(GlxProto
):
755 GlxProto
.__init
__(self
)
756 self
.last_category
= ""
757 self
.license
= license
.bsd_license_template
% ( \
758 """Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
759 (C) Copyright IBM Corporation 2004""", "PRECISION INSIGHT, IBM")
762 def printRealHeader(self
):
764 * \\file indirect_init.c
765 * Initialize indirect rendering dispatch table.
767 * \\author Kevin E. Martin <kevin@precisioninsight.com>
768 * \\author Brian Paul <brian@precisioninsight.com>
769 * \\author Ian Romanick <idr@us.ibm.com>
772 #include "indirect_init.h"
773 #include "indirect.h"
778 * No-op function used to initialize functions that have no GLX protocol
781 static int NoOp(void)
787 * Create and initialize a new GL dispatch table. The table is initialized
788 * with GLX indirect rendering protocol functions.
790 __GLapi * __glXNewIndirectAPI( void )
795 entries = _glapi_get_dispatch_table_size();
796 glAPI = (__GLapi *) Xmalloc(entries * sizeof(void *));
798 /* first, set all entries to point to no-op functions */
801 void **dispatch = (void **) glAPI;
802 for (i = 0; i < entries; i++) {
803 dispatch[i] = (void *) NoOp;
807 /* now, initialize the entries we understand */"""
809 def printRealFooter(self
):
815 def printFunction(self
, f
):
816 if f
.fn_offset
< 0 or f
.ignore
: return
818 if f
.category
!= self
.last_category
:
819 self
.last_category
= f
.category
821 print ' /* %s */' % (self
.last_category
)
824 print ' glAPI->%s = __indirect_gl%s;' % (f
.name
, f
.name
)
827 class PrintGlxProtoInit_h(GlxProto
):
829 GlxProto
.__init
__(self
)
830 self
.last_category
= ""
831 self
.license
= license
.bsd_license_template
% ( \
832 """Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
833 (C) Copyright IBM Corporation 2004""", "PRECISION INSIGHT, IBM")
836 def printRealHeader(self
):
840 * Prototypes for indirect rendering functions.
842 * \\author Kevin E. Martin <kevin@precisioninsight.com>
843 * \\author Ian Romanick <idr@us.ibm.com>
846 #if !defined( _INDIRECT_H_ )
847 # define _INDIRECT_H_
850 printVisibility( "HIDDEN", "hidden" )
853 def printRealFooter(self
):
854 print "# undef HIDDEN"
855 print "#endif /* !defined( _INDIRECT_H_ ) */"
857 def printFunction(self
, f
):
858 if f
.fn_offset
< 0 or f
.ignore
: return
859 print 'extern HIDDEN %s __indirect_gl%s(%s);' % (f
.fn_return_type
, f
.name
, f
.get_parameter_string())
862 class PrintGlxSizeStubs(GlxProto
):
864 GlxProto
.__init
__(self
)
865 self
.license
= license
.bsd_license_template
% ( "(C) Copyright IBM Corporation 2004", "IBM")
867 self
.glx_enum_sigs
= {}
869 def printRealHeader(self
):
871 print '#include <GL/gl.h>'
872 print '#include "indirect_size.h"'
879 printVisibility( "INTERNAL", "internal" )
882 print '#ifdef HAVE_ALIAS'
883 print '# define ALIAS2(from,to) \\'
884 print ' INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\'
885 print ' __attribute__ ((alias( # to )));'
886 print '# define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )'
888 print '# define ALIAS(from,to) \\'
889 print ' INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\'
890 print ' { return __gl ## to ## _size( e ); }'
895 def printRealFooter(self
):
896 for a
in self
.aliases
:
899 def printFunction(self
, f
):
900 if self
.glx_enum_functions
.has_key(f
.name
):
901 ef
= self
.glx_enum_functions
[f
.name
]
903 sig
= ef
.signature();
904 if self
.glx_enum_sigs
.has_key(sig
):
905 n
= self
.glx_enum_sigs
[sig
];
906 a
= 'ALIAS( %s, %s )' % (f
.name
, n
)
907 self
.aliases
.append(a
)
910 self
.glx_enum_sigs
[sig
] = f
.name
;
914 class PrintGlxSizeStubs_h(GlxProto
):
916 GlxProto
.__init
__(self
)
917 self
.license
= license
.bsd_license_template
% ( "(C) Copyright IBM Corporation 2004", "IBM")
919 self
.glx_enum_sigs
= {}
921 def printRealHeader(self
):
925 * Prototypes for functions used to determine the number of data elements in
926 * various GLX protocol messages.
928 * \\author Ian Romanick <idr@us.ibm.com>
931 #if !defined( _GLXSIZE_H_ )
939 printVisibility( "INTERNAL", "internal" );
942 def printRealFooter(self
):
944 print "# undef INTERNAL"
946 print "# undef FASTCALL"
947 print "#endif /* !defined( _GLXSIZE_H_ ) */"
950 def printFunction(self
, f
):
951 if self
.glx_enum_functions
.has_key(f
.name
):
952 ef
= self
.glx_enum_functions
[f
.name
]
953 print 'extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (f
.name
)
957 print "Usage: %s [-f input_file_name] [-m output_mode]" % sys
.argv
[0]
961 if __name__
== '__main__':
962 file_name
= "gl_API.xml"
965 (args
, trail
) = getopt
.getopt(sys
.argv
[1:], "f:m:")
970 for (arg
,val
) in args
:
977 dh
= PrintGlxProtoStubs()
978 elif mode
== "init_c":
979 dh
= PrintGlxProtoInit_c()
980 elif mode
== "init_h":
981 dh
= PrintGlxProtoInit_h()
982 elif mode
== "size_c":
983 dh
= PrintGlxSizeStubs()
984 elif mode
== "size_h":
985 dh
= PrintGlxSizeStubs_h()
989 parser
= make_parser()
990 parser
.setFeature(feature_namespaces
, 0)
991 parser
.setContentHandler(dh
)