- Revert: Change index parameter types from int to size_t to make 0-based range implicit.

- Add checks that index values are >= 0.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@409 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2011-12-08 10:22:15 +00:00
parent 64e08c2918
commit ef64033467
15 changed files with 137 additions and 51 deletions

View File

@@ -114,6 +114,14 @@ def make_cpptoc_function_impl_new(name, func, defined_names):
'\n if ('+arg_name+'Count > 0 && !'+arg_name+')'\
'\n return'+retval_default+';'
# check index params
index_params = arg.parent.get_attrib_list('index_param')
if not index_params is None and arg_name in index_params:
result += comment+\
'\n DCHECK('+arg_name+' >= 0);'\
'\n if ('+arg_name+' < 0)'\
'\n return'+retval_default+';'
if len(optional) > 0:
result += '\n // Unverified params: '+string.join(optional,', ')

View File

@@ -118,7 +118,15 @@ def make_ctocpp_function_impl_new(clsname, name, func):
result += comment+\
'\n DCHECK(!'+arg_name+'.empty());'\
'\n if ('+arg_name+'.empty())'\
'\n return'+retval_default+';'
'\n return'+retval_default+';'
# check index params
index_params = arg.parent.get_attrib_list('index_param')
if not index_params is None and arg_name in index_params:
result += comment+\
'\n DCHECK('+arg_name+' >= 0);'\
'\n if ('+arg_name+' < 0)'\
'\n return'+retval_default+';'
if len(optional) > 0:
result += '\n // Unverified params: '+string.join(optional,', ')

View File

@@ -79,6 +79,8 @@ Supported method/function attributes:
resulting C API function.
optional_param=[param] (Optional) Parameter name that will be optional
instead of required.
index_param=[param] (Optional) Parameter name representing an index
value that will be verified as >= 0.
default_retval=[string] (Required for enumeration types, Optional for other
types) Specify the default return value.
count_func=[param:func] (Required for non-const non-string std::vector