Add standard argument checks as part of translator code generation.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@219 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2011-04-18 23:25:17 +00:00
parent 1f7a4b4566
commit 026193a513
2 changed files with 14 additions and 0 deletions

View File

@ -39,6 +39,17 @@ def make_cpptoc_impl_new(name, func, defined_names):
result += '\n // END DELETE BEFORE MODIFYING'
# NULL check all pointer arguments.
if len(parts['args']) > 0:
check = [];
for arg in parts['args']:
if arg.find('*') >= 0:
argname = string.split(arg)[-1];
result += '\n DCHECK('+argname+');'
check.append('!'+argname);
result += '\n if ('+string.join(check,' || ')+')'
result += '\n return;'
result += '\n}\n\n'
return result

View File

@ -46,6 +46,9 @@ def make_ctocpp_impl_new(clsname, name, func):
result += '\n // END DELETE BEFORE MODIFYING'
result += '\n if (CEF_MEMBER_MISSING(struct_, '+func.get_capi_name()+'))'
result += '\n return;'
result += '\n}\n\n'
return result