summaryrefslogtreecommitdiff
path: root/src/gen_dispatch.py
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2014-03-28 14:27:29 -0700
committerEric Anholt <eric@anholt.net>2014-03-28 16:33:53 -0700
commit11a946cbf5ebd4ba79915ab06434847ae2581e47 (patch)
tree48b6154e441d1c2c1ea9e3b866837f2d45b77d6c /src/gen_dispatch.py
parentea12f935c14351a26a721fc6ffee6c67b53b0e15 (diff)
downloadlibepoxy-11a946cbf5ebd4ba79915ab06434847ae2581e47.tar.gz
Prefer non-aliased functions when resolving.
This increases the size of the library, but avoids some of the concerns that have been brought up with the library silently switching you from glWhateverEXT() to glWhatever() if there might be slight behavior differences between the two that hadn't been identified. The downside is that it means we can't share the resolver functions among aliases.
Diffstat (limited to 'src/gen_dispatch.py')
-rwxr-xr-xsrc/gen_dispatch.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py
index 6aba85d..aee4308 100755
--- a/src/gen_dispatch.py
+++ b/src/gen_dispatch.py
@@ -540,9 +540,12 @@ class Generator(object):
providers = []
# Make a local list of all the providers for this alias group
- for provider in func.providers.values():
+ alias_root = func;
+ if func.alias_func:
+ alias_root = func.alias_func
+ for provider in alias_root.providers.values():
providers.append(provider)
- for alias_func in func.alias_exts:
+ for alias_func in alias_root.alias_exts:
for provider in alias_func.providers.values():
providers.append(provider)
@@ -562,6 +565,10 @@ class Generator(object):
for provider in alias_func.providers.values():
providers.append(provider)
+ def provider_sort(provider):
+ return (provider.name != func.name, provider.name)
+ providers.sort(key=provider_sort);
+
if len(providers) != 1:
self.outln(' static const enum {0}_provider providers[] = {{'.format(self.target))
for provider in providers:
@@ -591,7 +598,7 @@ class Generator(object):
# Writes out the thunk that fetches the (win32) dispatch table
# and calls through its entrypoint.
- dispatch_table_entry = 'dispatch_table->p{0}'.format(func.alias_name)
+ dispatch_table_entry = 'dispatch_table->p{0}'.format(func.name)
self.outln('static __stdcall {0}'.format(func.ret_type))
self.outln('epoxy_{0}_dispatch_table_thunk({1})'.format(func.wrapped_name, func.args_decl))
@@ -637,7 +644,7 @@ class Generator(object):
func.args_decl))
self.outln('{')
self.outln(' epoxy_{0} = (void *)epoxy_{1}_resolver();'.format(func.wrapped_name,
- func.alias_name))
+ func.name))
if func.ret_type == 'void':
self.outln(' epoxy_{0}({1});'.format(func.wrapped_name,
@@ -772,9 +779,7 @@ class Generator(object):
self.outln('struct dispatch_table {')
for func in self.sorted_functions:
- # Aliases don't get their own slot, since they use a shared resolver.
- if func.alias_name == func.name:
- self.outln(' {0} p{1};'.format(func.ptr_type, func.name))
+ self.outln(' {0} p{1};'.format(func.ptr_type, func.name))
self.outln('};')
self.outln('')
@@ -794,23 +799,19 @@ class Generator(object):
self.write_provider_resolver()
for func in self.sorted_functions:
- if not func.alias_func:
- self.write_function_ptr_resolver(func)
+ self.write_function_ptr_resolver(func)
self.outln('#if USING_DISPATCH_TABLE')
for func in self.sorted_functions:
- if not func.alias_func:
- self.write_dispatch_table_rewrite_stub(func)
+ self.write_dispatch_table_rewrite_stub(func)
for func in self.sorted_functions:
self.write_dispatch_table_thunk(func)
self.outln('static struct dispatch_table resolver_table = {')
for func in self.sorted_functions:
- # Aliases don't get their own slot, since they use a shared resolver.
- if func.alias_name == func.name:
- self.outln(' .p{0} = epoxy_{0}_rewrite_stub,'.format(func.name))
+ self.outln(' .p{0} = epoxy_{0}_rewrite_stub,'.format(func.name))
self.outln('};')
self.outln('')