47be8c5b4af09b6441915a355fa6ce1d310796f6
3 # Mesa 3-D graphics library
6 # Copyright (C) 2010 LunarG Inc.
8 # Permission is hereby granted, free of charge, to any person obtaining a
9 # copy of this software and associated documentation files (the "Software"),
10 # to deal in the Software without restriction, including without limitation
11 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 # and/or sell copies of the Software, and to permit persons to whom the
13 # Software is furnished to do so, subject to the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 # DEALINGS IN THE SOFTWARE.
27 # Chia-I Wu <olv@lunarg.com>
31 from optparse
import OptionParser
33 # number of dynamic entries
34 ABI_NUM_DYNAMIC_ENTRIES
= 256
36 class ABIEntry(object):
37 """Represent an ABI entry."""
39 _match_c_param
= re
.compile(
40 '^(?P<type>[\w\s*]+?)(?P<name>\w+)(\[(?P<array>\d+)\])?$')
42 def __init__(self
, cols
, attrs
):
45 self
.slot
= attrs
['slot']
46 self
.hidden
= attrs
['hidden']
47 self
.alias
= attrs
['alias']
48 self
.handcode
= attrs
['handcode']
50 def c_prototype(self
):
51 return '%s %s(%s)' % (self
.c_return(), self
.name
, self
.c_params())
61 """Return the parameter list used in the entry prototype."""
63 for t
, n
, a
in self
.params
:
64 sep
= '' if t
.endswith('*') else ' '
65 arr
= '[%d]' % a
if a
else ''
66 c_params
.append(t
+ sep
+ n
+ arr
)
68 c_params
.append('void')
70 return ", ".join(c_params
)
73 """Return the argument list used in the entry invocation."""
75 for t
, n
, a
in self
.params
:
78 return ", ".join(c_args
)
80 def _parse(self
, cols
):
90 elif len(cols
) == 1 and cols
[0] == 'void':
94 params
.append(self
._parse
_param
(val
))
100 def _parse_param(self
, c_param
):
101 m
= self
._match
_c
_param
.match(c_param
)
103 raise Exception('unrecognized param ' + c_param
)
105 c_type
= m
.group('type').strip()
106 c_name
= m
.group('name')
107 c_array
= m
.group('array')
108 c_array
= int(c_array
) if c_array
else 0
110 return (c_type
, c_name
, c_array
)
113 return self
.c_prototype()
115 def __cmp__(self
, other
):
116 # compare slot, alias, and then name
117 res
= cmp(self
.slot
, other
.slot
)
121 elif not other
.alias
:
125 res
= cmp(self
.name
, other
.name
)
129 def abi_parse_xml(xml
):
130 """Parse a GLAPI XML file for ABI entries."""
132 GLAPI
= "./%s/../glapi/gen" % (os
.path
.dirname(sys
.argv
[0]))
133 sys
.path
.append(GLAPI
)
134 import gl_XML
, glX_XML
136 api
= gl_XML
.parse_GL_API(xml
, glX_XML
.glx_item_factory())
139 for func
in api
.functionIterateByOffset():
140 # make sure func.name appear first
141 entry_points
= func
.entry_points
[:]
142 entry_points
.remove(func
.name
)
143 entry_points
.insert(0, func
.name
)
145 for name
in entry_points
:
148 'hidden': not func
.is_static_entry_point(name
),
149 'alias': None if name
== func
.name
else func
.name
,
150 'handcode': bool(func
.has_different_protocol(name
)),
156 alias
= entry_dict
[attrs
['alias']]
158 raise Exception('failed to alias %s' % attrs
['alias'])
160 raise Exception('recursive alias %s' % ent
.name
)
161 attrs
['alias'] = alias
162 if attrs
['handcode']:
163 attrs
['handcode'] = func
.static_glx_name(name
)
165 attrs
['handcode'] = None
167 if entry_dict
.has_key(name
):
168 raise Exception('%s is duplicated' % (name
))
171 cols
.append(func
.return_type
)
173 params
= func
.get_parameter_string(name
)
174 cols
.extend([p
.strip() for p
in params
.split(',')])
176 ent
= ABIEntry(cols
, attrs
)
177 entry_dict
[ent
.name
] = ent
179 entries
= entry_dict
.values()
184 def abi_parse_line(line
):
185 cols
= [col
.strip() for col
in line
.split(',')]
194 # extract attributes from the first column
195 vals
= cols
[0].split(':')
198 if val
.startswith('slot='):
199 attrs
['slot'] = int(val
[5:])
200 elif val
== 'hidden':
201 attrs
['hidden'] = True
202 elif val
.startswith('alias='):
203 attrs
['alias'] = val
[6:]
204 elif val
.startswith('handcode='):
205 attrs
['handcode'] = val
[9:]
209 raise Exception('unknown attribute %s' % val
)
214 def abi_parse(filename
):
215 """Parse a CSV file for ABI entries."""
216 fp
= open(filename
) if filename
!= '-' else sys
.stdin
217 lines
= [line
.strip() for line
in fp
.readlines()
218 if not line
.startswith('#') and line
.strip()]
223 attrs
, cols
= abi_parse_line(line
)
225 # post-process attributes
228 alias
= entry_dict
[attrs
['alias']]
230 raise Exception('failed to alias %s' % attrs
['alias'])
232 raise Exception('recursive alias %s' % ent
.name
)
234 attrs
['alias'] = alias
239 if attrs
['slot'] < 0:
241 elif attrs
['slot'] != slot
:
242 raise Exception('invalid slot in %s' % (line
))
244 ent
= ABIEntry(cols
, attrs
)
245 if entry_dict
.has_key(ent
.name
):
246 raise Exception('%s is duplicated' % (ent
.name
))
247 entry_dict
[ent
.name
] = ent
249 entries
= entry_dict
.values()
254 def abi_sanity_check(entries
):
259 last_slot
= entries
[-1].slot
261 for slot
in xrange(last_slot
+ 1):
262 if entries
[i
].slot
!= slot
:
263 raise Exception('entries are not ordered by slots')
265 raise Exception('first entry of slot %d aliases %s'
266 % (slot
, entries
[i
].alias
.name
))
268 while i
< len(entries
) and entries
[i
].slot
== slot
:
270 if not handcode
and ent
.handcode
:
271 handcode
= ent
.handcode
272 elif ent
.handcode
!= handcode
:
273 raise Exception('two aliases with handcode %s != %s',
274 ent
.handcode
, handcode
)
276 if ent
.name
in all_names
:
277 raise Exception('%s is duplicated' % (ent
.name
))
278 if ent
.alias
and ent
.alias
.name
not in all_names
:
279 raise Exception('failed to alias %s' % (ent
.alias
.name
))
280 all_names
.append(ent
.name
)
283 raise Exception('there are %d invalid entries' % (len(entries
) - 1))
285 class ABIPrinter(object):
288 def __init__(self
, entries
):
289 self
.entries
= entries
291 # sort entries by their names
292 self
.entries_sorted_by_names
= self
.entries
[:]
293 self
.entries_sorted_by_names
.sort(lambda x
, y
: cmp(x
.name
, y
.name
))
295 self
.indent
= ' ' * 3
296 self
.noop_warn
= 'noop_warn'
297 self
.noop_generic
= 'noop_generic'
299 self
.api_defines
= []
300 self
.api_headers
= ['"KHR/khrplatform.h"']
301 self
.api_call
= 'KHRONOS_APICALL'
302 self
.api_entry
= 'KHRONOS_APIENTRY'
303 self
.api_attrs
= 'KHRONOS_APIATTRIBUTES'
307 self
.lib_need_table_size
= True
308 self
.lib_need_noop_array
= True
309 self
.lib_need_stubs
= True
310 self
.lib_need_entries
= True
313 return '/* This file is automatically generated by mapi_abi.py. Do not modify. */'
315 def c_public_includes(self
):
316 """Return includes of the client API headers."""
317 defines
= ['#define ' + d
for d
in self
.api_defines
]
318 includes
= ['#include ' + h
for h
in self
.api_headers
]
319 return "\n".join(defines
+ includes
)
321 def need_entry_point(self
, ent
):
322 """Return True if an entry point is needed for the entry."""
323 # non-handcode hidden aliases may share the entry they alias
324 use_alias
= (ent
.hidden
and ent
.alias
and not ent
.handcode
)
327 def c_public_declarations(self
, prefix
):
328 """Return the declarations of public entry points."""
330 for ent
in self
.entries
:
331 if not self
.need_entry_point(ent
):
333 export
= self
.api_call
if not ent
.hidden
else ''
334 decls
.append(self
._c
_decl
(ent
, prefix
, True, export
) + ';')
336 return "\n".join(decls
)
338 def c_mapi_table(self
):
339 """Return defines of the dispatch table size."""
340 num_static_entries
= 0
341 for ent
in self
.entries
:
343 num_static_entries
+= 1
345 return ('#define MAPI_TABLE_NUM_STATIC %d\n' + \
346 '#define MAPI_TABLE_NUM_DYNAMIC %d') % (
347 num_static_entries
, ABI_NUM_DYNAMIC_ENTRIES
)
349 def c_mapi_table_initializer(self
, prefix
):
350 """Return the array initializer for mapi_table_fill."""
351 entries
= [self
._c
_function
(ent
, prefix
)
352 for ent
in self
.entries
if not ent
.alias
]
353 pre
= self
.indent
+ '(mapi_proc) '
354 return pre
+ (',\n' + pre
).join(entries
)
356 def c_mapi_table_spec(self
):
357 """Return the spec for mapi_init."""
360 for ent
in self
.entries
:
365 line
+= '%s\\0' % ent
.name
369 return self
.indent
+ self
.indent
.join(specv1
)
371 def _c_function(self
, ent
, prefix
, mangle
=False, stringify
=False):
372 """Return the function name of an entry."""
374 True: { True: '%s_STR(%s)', False: '%s(%s)' },
375 False: { True: '"%s%s"', False: '%s%s' },
377 fmt
= formats
[prefix
.isupper()][stringify
]
379 if mangle
and ent
.hidden
:
380 name
= '_dispatch_stub_' + str(ent
.slot
)
381 return fmt
% (prefix
, name
)
383 def _c_function_call(self
, ent
, prefix
):
384 """Return the function name used for calling."""
386 # _c_function does not handle this case
387 formats
= { True: '%s(%s)', False: '%s%s' }
388 fmt
= formats
[prefix
.isupper()]
389 name
= fmt
% (prefix
, ent
.handcode
)
390 elif self
.need_entry_point(ent
):
391 name
= self
._c
_function
(ent
, prefix
, True)
393 name
= self
._c
_function
(ent
.alias
, prefix
, True)
396 def _c_decl(self
, ent
, prefix
, mangle
=False, export
=''):
397 """Return the C declaration for the entry."""
398 decl
= '%s %s %s(%s)' % (ent
.c_return(), self
.api_entry
,
399 self
._c
_function
(ent
, prefix
, mangle
), ent
.c_params())
401 decl
= export
+ ' ' + decl
403 decl
+= ' ' + self
.api_attrs
407 def _c_cast(self
, ent
):
408 """Return the C cast for the entry."""
409 cast
= '%s (%s *)(%s)' % (
410 ent
.c_return(), self
.api_entry
, ent
.c_params())
414 def c_private_declarations(self
, prefix
):
415 """Return the declarations of private functions."""
416 decls
= [self
._c
_decl
(ent
, prefix
) + ';'
417 for ent
in self
.entries
if not ent
.alias
]
419 return "\n".join(decls
)
421 def c_public_dispatches(self
, prefix
):
422 """Return the public dispatch functions."""
424 for ent
in self
.entries
:
425 if not self
.need_entry_point(ent
):
428 export
= self
.api_call
if not ent
.hidden
else ''
430 proto
= self
._c
_decl
(ent
, prefix
, True, export
)
431 cast
= self
._c
_cast
(ent
)
437 stmt1
+= 'const struct mapi_table *_tbl = u_current_get();'
439 stmt2
+= 'mapi_func _func = ((const mapi_func *) _tbl)[%d];' % (
442 stmt3
+= '%s((%s) _func)(%s);' % (ret
, cast
, ent
.c_args())
444 disp
= '%s\n{\n%s\n%s\n%s\n}' % (proto
, stmt1
, stmt2
, stmt3
)
447 disp
= '#if 0\n' + disp
+ '\n#endif'
449 dispatches
.append(disp
)
451 return '\n\n'.join(dispatches
)
453 def c_public_initializer(self
, prefix
):
454 """Return the initializer for public dispatch functions."""
456 for ent
in self
.entries
:
460 name
= '%s(mapi_func) %s' % (self
.indent
,
461 self
._c
_function
_call
(ent
, prefix
))
464 return ',\n'.join(names
)
466 def c_stub_string_pool(self
):
467 """Return the string pool for use by stubs."""
468 # sort entries by their names
469 sorted_entries
= self
.entries
[:]
470 sorted_entries
.sort(lambda x
, y
: cmp(x
.name
, y
.name
))
475 for ent
in sorted_entries
:
477 pool
.append('%s' % (ent
.name
))
478 count
+= len(ent
.name
) + 1
480 pool_str
= self
.indent
+ '"' + \
481 ('\\0"\n' + self
.indent
+ '"').join(pool
) + '";'
482 return (pool_str
, offsets
)
484 def c_stub_initializer(self
, prefix
, pool_offsets
):
485 """Return the initializer for struct mapi_stub array."""
487 for ent
in self
.entries_sorted_by_names
:
488 stubs
.append('%s{ (void *) %d, %d, NULL }' % (
489 self
.indent
, pool_offsets
[ent
], ent
.slot
))
491 return ',\n'.join(stubs
)
493 def c_noop_functions(self
, prefix
, warn_prefix
):
494 """Return the noop functions."""
496 for ent
in self
.entries
:
500 proto
= self
._c
_decl
(ent
, prefix
, False, 'static')
502 stmt1
= self
.indent
+ '%s(%s);' % (self
.noop_warn
,
503 self
._c
_function
(ent
, warn_prefix
, False, True))
506 stmt2
= self
.indent
+ 'return (%s) 0;' % (ent
.ret
)
507 noop
= '%s\n{\n%s\n%s\n}' % (proto
, stmt1
, stmt2
)
509 noop
= '%s\n{\n%s\n}' % (proto
, stmt1
)
513 return '\n\n'.join(noops
)
515 def c_noop_initializer(self
, prefix
, use_generic
):
516 """Return an initializer for the noop dispatch table."""
517 entries
= [self
._c
_function
(ent
, prefix
)
518 for ent
in self
.entries
if not ent
.alias
]
520 entries
= [self
.noop_generic
] * len(entries
)
522 entries
.extend([self
.noop_generic
] * ABI_NUM_DYNAMIC_ENTRIES
)
524 pre
= self
.indent
+ '(mapi_func) '
525 return pre
+ (',\n' + pre
).join(entries
)
527 def c_asm_gcc(self
, prefix
):
530 asm
.append('__asm__(')
531 for ent
in self
.entries
:
532 if not self
.need_entry_point(ent
):
535 name
= self
._c
_function
(ent
, prefix
, True, True)
541 asm
.append('".hidden "%s"\\n"' % (name
))
544 asm
.append('".globl "%s"\\n"' % (name
))
545 asm
.append('".set "%s", "%s"\\n"' % (name
,
546 self
._c
_function
(ent
.alias
, prefix
, True, True)))
548 asm
.append('STUB_ASM_ENTRY(%s)"\\n"' % (name
))
549 asm
.append('"\\t"STUB_ASM_CODE("%d")"\\n"' % (ent
.slot
))
556 return "\n".join(asm
)
558 def output_for_lib(self
):
559 print self
.c_notice()
566 print '#ifdef MAPI_TMP_DEFINES'
567 print self
.c_public_includes()
569 print self
.c_public_declarations(self
.prefix_lib
)
570 print '#undef MAPI_TMP_DEFINES'
571 print '#endif /* MAPI_TMP_DEFINES */'
573 if self
.lib_need_table_size
:
575 print '#ifdef MAPI_TMP_TABLE'
576 print self
.c_mapi_table()
577 print '#undef MAPI_TMP_TABLE'
578 print '#endif /* MAPI_TMP_TABLE */'
580 if self
.lib_need_noop_array
:
582 print '#ifdef MAPI_TMP_NOOP_ARRAY'
585 print self
.c_noop_functions(self
.prefix_noop
, self
.prefix_warn
)
587 print 'const mapi_func table_%s_array[] = {' % (self
.prefix_noop
)
588 print self
.c_noop_initializer(self
.prefix_noop
, False)
591 print '#else /* DEBUG */'
593 print 'const mapi_func table_%s_array[] = {' % (self
.prefix_noop
)
594 print self
.c_noop_initializer(self
.prefix_noop
, True)
597 print '#endif /* DEBUG */'
598 print '#undef MAPI_TMP_NOOP_ARRAY'
599 print '#endif /* MAPI_TMP_NOOP_ARRAY */'
601 if self
.lib_need_stubs
:
602 pool
, pool_offsets
= self
.c_stub_string_pool()
604 print '#ifdef MAPI_TMP_PUBLIC_STUBS'
605 print 'static const char public_string_pool[] ='
608 print 'static const struct mapi_stub public_stubs[] = {'
609 print self
.c_stub_initializer(self
.prefix_lib
, pool_offsets
)
611 print '#undef MAPI_TMP_PUBLIC_STUBS'
612 print '#endif /* MAPI_TMP_PUBLIC_STUBS */'
614 if self
.lib_need_entries
:
616 print '#ifdef MAPI_TMP_PUBLIC_ENTRIES'
617 print self
.c_public_dispatches(self
.prefix_lib
)
619 print 'static const mapi_func public_entries[] = {'
620 print self
.c_public_initializer(self
.prefix_lib
)
622 print '#undef MAPI_TMP_PUBLIC_ENTRIES'
623 print '#endif /* MAPI_TMP_PUBLIC_ENTRIES */'
626 print '#ifdef MAPI_TMP_STUB_ASM_GCC'
627 print self
.c_asm_gcc(self
.prefix_lib
)
628 print '#undef MAPI_TMP_STUB_ASM_GCC'
629 print '#endif /* MAPI_TMP_STUB_ASM_GCC */'
631 def output_for_app(self
):
632 print self
.c_notice()
634 print self
.c_private_declarations(self
.prefix_app
)
636 print '#ifdef API_TMP_DEFINE_SPEC'
638 print 'static const char %s_spec[] =' % (self
.prefix_app
)
639 print self
.c_mapi_table_spec()
641 print 'static const mapi_proc %s_procs[] = {' % (self
.prefix_app
)
642 print self
.c_mapi_table_initializer(self
.prefix_app
)
645 print '#endif /* API_TMP_DEFINE_SPEC */'
647 class GLAPIPrinter(ABIPrinter
):
648 """OpenGL API Printer"""
650 def __init__(self
, entries
, api
=None):
651 api_entries
= self
._get
_api
_entries
(entries
, api
)
652 super(GLAPIPrinter
, self
).__init
__(api_entries
)
654 self
.api_defines
= ['GL_GLEXT_PROTOTYPES']
655 self
.api_headers
= ['"GL/gl.h"', '"GL/glext.h"']
656 self
.api_call
= 'GLAPI'
657 self
.api_entry
= 'APIENTRY'
660 self
.prefix_lib
= 'GLAPI_PREFIX'
661 self
.prefix_app
= '_mesa_'
662 self
.prefix_noop
= 'noop'
663 self
.prefix_warn
= self
.prefix_lib
665 self
.c_header
= self
._get
_c
_header
()
667 def _get_api_entries(self
, entries
, api
):
668 """Override the entry attributes according to API."""
679 # override 'hidden' and 'handcode'
680 ent
.hidden
= ent
.name
not in api
683 ent
.alias
= api_entries
[ent
.alias
.name
]
685 api_entries
[ent
.name
] = ent
688 missed
= [name
for name
in api
if name
not in api_entries
]
690 raise Exception('%s is missing' % str(missed
))
692 entries
= api_entries
.values()
697 def _get_c_header(self
):
698 header
= """#ifndef _GLAPI_TMP_H_
699 #define _GLAPI_TMP_H_
700 #ifdef USE_MGL_NAMESPACE
701 #define GLAPI_PREFIX(func) mgl##func
702 #define GLAPI_PREFIX_STR(func) "mgl"#func
704 #define GLAPI_PREFIX(func) gl##func
705 #define GLAPI_PREFIX_STR(func) "gl"#func
706 #endif /* USE_MGL_NAMESPACE */
709 typedef int GLclampx;
710 #endif /* _GLAPI_TMP_H_ */"""
714 class ES1APIPrinter(GLAPIPrinter
):
715 """OpenGL ES 1.x API Printer"""
717 def __init__(self
, entries
):
734 'ClientActiveTexture',
742 'CompressedTexImage2D',
743 'CompressedTexSubImage2D',
754 'DisableClientState',
771 'GetBufferParameteriv',
865 'EGLImageTargetTexture2DOES',
866 'EGLImageTargetRenderbufferStorageOES',
868 'GetBufferPointervOES',
871 # GL_EXT_multi_draw_arrays
872 'MultiDrawArraysEXT',
873 'MultiDrawElementsEXT',
874 # GL_OES_blend_equation_separate
875 'BlendEquationSeparateOES',
876 # GL_OES_blend_func_separate
877 'BlendFuncSeparateOES',
878 # GL_OES_blend_subtract
880 # GL_OES_draw_texture
906 'MultiTexCoord4xOES',
913 'SampleCoveragexOES',
925 'GetTexParameterxvOES',
926 'PointParameterxOES',
927 'PointParameterxvOES',
929 # GL_OES_framebuffer_object
930 'BindFramebufferOES',
931 'BindRenderbufferOES',
932 'CheckFramebufferStatusOES',
933 'DeleteFramebuffersOES',
934 'DeleteRenderbuffersOES',
935 'FramebufferRenderbufferOES',
936 'FramebufferTexture2DOES',
938 'GenFramebuffersOES',
939 'GenRenderbuffersOES',
940 'GetFramebufferAttachmentParameterivOES',
941 'GetRenderbufferParameterivOES',
944 'RenderbufferStorageOES',
945 # GL_OES_point_size_array
946 'PointSizePointerOES',
947 # GL_OES_query_matrix
949 # GL_OES_single_precision
956 # GL_OES_texture_cube_map
968 super(ES1APIPrinter
, self
).__init
__(entries
, es1_api
)
969 self
.prefix_lib
= 'gl'
970 self
.prefix_warn
= 'gl'
972 def _get_c_header(self
):
973 header
= """#ifndef _GLAPI_TMP_H_
974 #define _GLAPI_TMP_H_
976 typedef int GLclampx;
977 #endif /* _GLAPI_TMP_H_ */"""
981 class ES2APIPrinter(GLAPIPrinter
):
982 """OpenGL ES 2.x API Printer"""
984 def __init__(self
, entries
):
989 "BindAttribLocation",
996 "BlendEquationSeparate",
1001 "CheckFramebufferStatus",
1008 "CompressedTexImage2D",
1009 "CompressedTexSubImage2D",
1011 "CopyTexSubImage2D",
1016 "DeleteFramebuffers",
1018 "DeleteRenderbuffers",
1026 "DisableVertexAttribArray",
1030 "EnableVertexAttribArray",
1033 "FramebufferRenderbuffer",
1034 "FramebufferTexture2D",
1043 "GetAttachedShaders",
1044 "GetAttribLocation",
1046 "GetBufferParameteriv",
1049 "GetFramebufferAttachmentParameteriv",
1051 "GetProgramInfoLog",
1053 "GetRenderbufferParameteriv",
1056 "GetShaderPrecisionFormat",
1059 "GetTexParameterfv",
1060 "GetTexParameteriv",
1063 "GetUniformLocation",
1064 "GetVertexAttribfv",
1065 "GetVertexAttribiv",
1066 "GetVertexAttribPointerv",
1080 "ReleaseShaderCompiler",
1081 "RenderbufferStorage",
1087 "StencilFuncSeparate",
1089 "StencilMaskSeparate",
1091 "StencilOpSeparate",
1127 "VertexAttribPointer",
1130 'EGLImageTargetTexture2DOES',
1131 'EGLImageTargetRenderbufferStorageOES',
1133 'GetBufferPointervOES',
1136 # GL_EXT_multi_draw_arrays
1137 'MultiDrawArraysEXT',
1138 'MultiDrawElementsEXT',
1140 'CompressedTexImage3DOES',
1141 'CompressedTexSubImage3DOES',
1142 'CopyTexSubImage3DOES',
1143 'FramebufferTexture3DOES',
1146 # GL_OES_get_program_binary
1147 'GetProgramBinaryOES',
1151 super(ES2APIPrinter
, self
).__init
__(entries
, es2_api
)
1152 self
.prefix_lib
= 'gl'
1153 self
.prefix_warn
= 'gl'
1155 def _get_c_header(self
):
1156 header
= """#ifndef _GLAPI_TMP_H_
1157 #define _GLAPI_TMP_H_
1158 typedef int GLfixed;
1159 typedef int GLclampx;
1160 #endif /* _GLAPI_TMP_H_ */"""
1164 class VGAPIPrinter(ABIPrinter
):
1165 """OpenVG API Printer"""
1167 def __init__(self
, entries
):
1168 super(VGAPIPrinter
, self
).__init
__(entries
)
1170 self
.api_defines
= ['VG_VGEXT_PROTOTYPES']
1171 self
.api_headers
= ['"VG/openvg.h"', '"VG/vgext.h"']
1172 self
.api_call
= 'VG_API_CALL'
1173 self
.api_entry
= 'VG_API_ENTRY'
1174 self
.api_attrs
= 'VG_API_EXIT'
1176 self
.prefix_lib
= 'vg'
1177 self
.prefix_app
= 'vega'
1178 self
.prefix_noop
= 'noop'
1179 self
.prefix_warn
= 'vg'
1182 printers
= ['glapi', 'es1api', 'es2api', 'vgapi']
1183 modes
= ['lib', 'app']
1185 parser
= OptionParser(usage
='usage: %prog [options] <filename>')
1186 parser
.add_option('-p', '--printer', dest
='printer',
1187 help='printer to use: %s' % (", ".join(printers
)))
1188 parser
.add_option('-m', '--mode', dest
='mode',
1189 help='target user: %s' % (", ".join(modes
)))
1191 options
, args
= parser
.parse_args()
1192 if not args
or options
.printer
not in printers
or \
1193 options
.mode
not in modes
:
1197 return (args
[0], options
)
1201 'vgapi': VGAPIPrinter
,
1202 'glapi': GLAPIPrinter
,
1203 'es1api': ES1APIPrinter
,
1204 'es2api': ES2APIPrinter
1207 filename
, options
= parse_args()
1209 if filename
.endswith('.xml'):
1210 entries
= abi_parse_xml(filename
)
1212 entries
= abi_parse(filename
)
1213 abi_sanity_check(entries
)
1215 printer
= printers
[options
.printer
](entries
)
1216 if options
.mode
== 'lib':
1217 printer
.output_for_lib()
1219 printer
.output_for_app()
1221 if __name__
== '__main__':