Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Unified Diff: ppapi/generators/idl_thunk.py

Issue 14161017: Pepper: Simplify idl_thunk implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ppapi/thunk/ppb_audio_input_dev_thunk.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/generators/idl_thunk.py
diff --git a/ppapi/generators/idl_thunk.py b/ppapi/generators/idl_thunk.py
index d183e4b9224e407b94403aa745925b285409c3a5..404938e2ed09fb13732a8f49f665f5e74469cb9c 100755
--- a/ppapi/generators/idl_thunk.py
+++ b/ppapi/generators/idl_thunk.py
@@ -279,60 +279,41 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args,
handle_errors = not (member.GetProperty('report_errors') == 'False')
out_params = _GetOutputParams(member, release)
if is_callback_func:
- # TODO(teravest): Reduce code duplication below.
body = '%s\n' % _MakeEnterLine(filenode, node, member, args[0],
handle_errors, args[len(args) - 1][1], meta)
- value = member.GetProperty('on_failure')
- if value is None:
- value = 'enter.retval()'
- if member.GetProperty('always_set_output_parameters'):
- body += 'if (enter.failed()) {\n'
- for param in out_params:
- body += ' memset(%s, 0, sizeof(*%s));\n' % (param, param)
- body += ' return %s;\n' % value
- body += '}\n'
- body += 'return enter.SetResult(%s);' % invocation
- meta.AddBuiltinInclude('string.h')
- else:
- body += 'if (enter.failed())\n'
- body += ' return %s;\n' % value
- body += 'return enter.SetResult(%s);' % invocation
+ failure_value = member.GetProperty('on_failure')
+ if failure_value is None:
+ failure_value = 'enter.retval()'
+ failure_return = 'return %s;' % failure_value
+ success_return = 'return enter.SetResult(%s);' % invocation
elif rtype == 'void':
body = '%s\n' % _MakeEnterLine(filenode, node, member, args[0],
handle_errors, None, meta)
- if member.GetProperty('always_set_output_parameters'):
- body += 'if (enter.succeeded()) {\n'
- body += ' %s;\n' % invocation
- body += ' return;\n'
- body += '}'
- for param in out_params:
- body += '\nmemset(%s, 0, sizeof(*%s));' % (param, param)
- meta.AddBuiltinInclude('string.h')
- else:
- body += 'if (enter.succeeded())\n'
- body += ' %s;' % invocation
-
+ failure_return = 'return;'
+ success_return = '%s;' % invocation # We don't return anything for void.
else:
- value = member.GetProperty('on_failure')
- if value is None:
- value = _GetDefaultFailureValue(rtype)
- if value is None:
- raise TGenError('No default value for rtype %s' % rtype)
-
body = '%s\n' % _MakeEnterLine(filenode, node, member, args[0],
handle_errors, None, meta)
- if member.GetProperty('always_set_output_parameters'):
- body += 'if (enter.failed()) {\n'
- for param in out_params:
- body += ' memset(%s, 0, sizeof(*%s));\n' % (param, param)
- body += ' return %s;\n' % value
- body += '}\n'
- body += 'return %s;' % invocation
- meta.AddBuiltinInclude('string.h')
- else:
- body += 'if (enter.failed())\n'
- body += ' return %s;\n' % value
- body += 'return %s;' % invocation
+ failure_value = member.GetProperty('on_failure')
+ if failure_value is None:
+ failure_value = _GetDefaultFailureValue(rtype)
+ if failure_value is None:
+ raise TGenError('No default value for rtype %s' % rtype)
dmichael (off chromium) 2013/04/18 15:41:15 I know this is not a new line, but I think it woul
+ failure_return = 'return %s;' % failure_value
+ success_return = 'return %s;' % invocation
+
+ if member.GetProperty('always_set_output_parameters'):
+ body += 'if (enter.failed()) {\n'
+ for param in out_params:
+ body += ' memset(%s, 0, sizeof(*%s));\n' % (param, param)
+ body += ' %s\n' % failure_return
+ body += '}\n'
+ body += '%s' % success_return
+ meta.AddBuiltinInclude('string.h')
+ else:
+ body += 'if (enter.failed())\n'
+ body += ' %s\n' % failure_return
+ body += '%s' % success_return
return body
« no previous file with comments | « no previous file | ppapi/thunk/ppb_audio_input_dev_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698