diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2016-03-30 12:22:44 -0700 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2016-03-31 16:03:59 -0700 |
commit | 1126121d42d5e2e43bc0bf7227e68a02283af029 (patch) | |
tree | d71e29ae4358b428ea4905fe327d86939fd4e4a8 | |
parent | efae890cd45708e18b112bd277824118c87a6eff (diff) |
glapi: glX_proto_send.py: simplify XCB string conversion
This makes the function a little simpler by using a special case for the
initial "ARB", and just walking the str as a sequence rather than
indexing into it.
It also uses a list to join rather than overwritting a str over and over
again.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_send.py | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py index 53881639c6..800f7a3efe 100644 --- a/src/mapi/glapi/gen/glX_proto_send.py +++ b/src/mapi/glapi/gen/glX_proto_send.py @@ -38,20 +38,25 @@ import glX_proto_common import license -def convertStringForXCB(string_): - tmp = "" - special = ["ARB"] - i = 0 - while i < len(string_): - if string_[i:i+3] in special: - tmp = '%s_%s' % (tmp, string_[i:i+3].lower()) - i = i + 2 - elif string_[i].isupper(): - tmp = '%s_%s' % (tmp, string_[i].lower()) +def convert_string_for_xcb(string_): + """Convert an OpenGL name into the form XCB wants. + + This means all lower, with more underscores. + + """ + new = [] + slice_ = 0 + + if string_.startswith('ARB'): + new.append('arb_') + slice_ = 4 + + for c in string_[slice_:]: + if c.isupper(): + new.extend(['_', c.lower()]) else: - tmp = '%s%s' % (tmp, string_[i]) - i += 1 - return tmp + new.append(c) + return ''.join(new) def hash_pixel_function(func): @@ -633,7 +638,7 @@ class PrintGlxProtoStubs(glX_proto_common.glx_print_proto): print ' printf("\\tUsing XCB.\\n");' print ' xcb_connection_t *c = XGetXCBConnection(dpy);' print ' (void) __glXFlushRenderBuffer(gc, gc->pc);' - xcb_name = 'xcb_glx%s' % convertStringForXCB(name) + xcb_name = 'xcb_glx%s' % convert_string_for_xcb(name) iparams = [] extra_iparams = [] |